.NODE

Exposing Information Through MINFO

Memory

void *emalloc(size_t size);
void *safe_emalloc(size_t nmemb, size_t size, size_t offset);
void *ecalloc(size_t nmemb, size_t siz);
void *erealloc(void *ptr, size_t size, int allow_failure);
void *pemalloc(size_t size, int persistent);
void *safe_pemalloc(size_t nmemb, size_t size, size_t offset, int persistent);
vpod *pecalloc(size_t nmemb, size_t siz, int persistent);
void *perealloc(void *ptr, size_t size, int allow_failure);

Allocates memory of size or ((nmemb*size)+offset) as appropriate. The meaning of these functions generally map to their ANSI-C equivalents. Any p* variant will conditionally allocate persistent memory. If the persistent flag is set to 0, or the non p* family of allocators is used, any memory allocated will be automatically freed at the end of a request.

Argument

Purpose

ptr

Already allocated pointer to be reallocated to a new size.

size

Number of bytes to allocate.

nmemb

Used with calloc and the safe_* family of allocators. Multiplied by size to allocate multiple contiguous blocks of equal size.

offset

Added to size*nmemb calculation to allocate additional "odd" bytes.

allow_failure

Ordinarily a failure in the underlying realloc() function will cause erealloc() to force the engine into bailout mode and end any running script. Setting this flag will allow a erealloc to fail quietly, returning NULL.

persistent

When set, the normal system allocation functions will be used rather than the per-request allocators.

char *estrdup(const char *s);
char *estrndup(const char *s, unsigned int length);
char *pestrdup(const char *s, persistent);
char *zend_strndup(const char *s, unsigned int length);

Duplicates a string of data ending with (but including) the first NULL byte or at length number of characters. Unlike most memory-related functions, the persistent version of estrndup() is named zend_strndup() and does not have a flag to interactively disable persistency.

Argument

Purpose

s

String to duplicate.

length

Length of data to be duplicated, if known.

persistent

When set, the normal system allocation functions will be used rather than the per-request allocators.

void efree(void *ptr);
void pefree(void *ptr, int persistent);

Frees a previously allocated block of memory. If that memory was allocated persistently, it must be freed the same way and vice versa. Using a persistent free on a non-persistent block of memory or the other way around will lead to corruption and a likely segfault.

int zend_set_memory_limit(unsigned int memory_limit);

Alters the php.ini specified memory limit. If memory limits aren't actually enabled, this function will return FAILURE.


The PHP Life Cycle

Variables from the Inside Out

Memory Management

Setting Up a Build Environment

Your First Extension

Returning Values

Accepting Parameters

Working with Arrays and HashTables

The Resource Data Type

PHP4 Objects

PHP5 Objects

Startup, Shutdown, and a Few Points in Between

INI Settings

Accessing Streams

Implementing Streams

Diverting the Stream

Configuration and Linking

Extension Generators

Setting Up a Host Environment

Advanced Embedding

Appendix A. A Zend API Reference

Appendix B. PHPAPI

Appendix C. Extending and Embedding Cookbook

Appendix D. Additional Resources





Extending and Embedding PHP
Extending and Embedding PHP
ISBN: 067232704X
EAN: 2147483647
Year: 2007
Pages: 175
Authors: Sara Golemon
Similar book on Amazon

Flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net