- Nuke persist_alloc().

This commit is contained in:
Andi Gutmans 2002-06-22 13:52:07 +00:00
parent c83f5a530d
commit b53569c9e8
7 changed files with 3 additions and 71 deletions

View File

@ -747,29 +747,6 @@ ZEND_API void _full_mem_check(int silent ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_D
#endif
ZEND_API int _persist_alloc(void *ptr ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
{
zend_mem_header *p = (zend_mem_header *) ((char *)ptr-sizeof(zend_mem_header)-MEM_HEADER_PADDING);
TSRMLS_FETCH();
#if ZEND_DEBUG
_mem_block_check(ptr, 1 ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
#endif
HANDLE_BLOCK_INTERRUPTIONS();
/* remove the block from the non persistent list */
REMOVE_POINTER_FROM_LIST(p);
p->persistent = 1;
/* add the block to the persistent list */
ADD_POINTER_TO_LIST(p);
HANDLE_UNBLOCK_INTERRUPTIONS();
return REAL_SIZE(p->size)+sizeof(zend_mem_header)+MEM_HEADER_PADDING;
}
/*
* Local variables:
* tab-width: 4

View File

@ -79,7 +79,6 @@ ZEND_API void *_ecalloc(size_t nmemb, size_t size ZEND_FILE_LINE_DC ZEND_FILE_LI
ZEND_API void *_erealloc(void *ptr, size_t size, int allow_failure ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC);
ZEND_API char *_estrdup(const char *s ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC);
ZEND_API char *_estrndup(const char *s, unsigned int length ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC);
ZEND_API int _persist_alloc(void *ptr ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC);
/* Standard wrapper macros */
#define emalloc(size) _emalloc((size) ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC)
@ -89,7 +88,6 @@ ZEND_API int _persist_alloc(void *ptr ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC);
#define erealloc_recoverable(ptr, size) _erealloc((ptr), (size), 1 ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC)
#define estrdup(s) _estrdup((s) ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC)
#define estrndup(s, length) _estrndup((s), (length) ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC)
#define persist_alloc(p) _persist_alloc((p) ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC)
/* Relay wrapper macros */
#define emalloc_rel(size) _emalloc((size) ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_CC)
@ -99,7 +97,6 @@ ZEND_API int _persist_alloc(void *ptr ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC);
#define erealloc_recoverable_rel(ptr, size) _erealloc((ptr), (size), 1 ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_CC)
#define estrdup_rel(s) _estrdup((s) ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_CC)
#define estrndup_rel(s, length) _estrndup((s), (length) ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_CC)
#define persist_alloc_rel(p) _persist_alloc((p) ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_CC)
/* Selective persistent/non persistent allocation macros */
#define pemalloc(size, persistent) ((persistent)?malloc(size):emalloc(size))

View File

@ -27,8 +27,7 @@
void free_zend_constant(zend_constant *c)
{
if (!(c->flags & CONST_PERSISTENT)
|| (c->flags & CONST_EFREE_PERSISTENT)) {
if (!(c->flags & CONST_PERSISTENT)) {
zval_dtor(&c->value);
}
free(c->name);
@ -40,9 +39,6 @@ void copy_zend_constant(zend_constant *c)
c->name = zend_strndup(c->name, c->name_len);
if (!(c->flags & CONST_PERSISTENT)) {
zval_copy_ctor(&c->value);
if (c->flags & CONST_EFREE_PERSISTENT) { /* persist_alloc()'d data */
persist_alloc(&c->value);
}
}
}
@ -265,8 +261,7 @@ ZEND_API int zend_register_constant(zend_constant *c TSRMLS_DC)
if (zend_hash_add(EG(zend_constants), lowercase_name, c->name_len, (void *) c, sizeof(zend_constant), NULL)==FAILURE) {
free(c->name);
if (!(c->flags & CONST_PERSISTENT)
|| (c->flags & CONST_EFREE_PERSISTENT)) {
if (!(c->flags & CONST_PERSISTENT)) {
zval_dtor(&c->value);
}
zend_error(E_NOTICE,"Constant %s already defined", lowercase_name);

View File

@ -25,10 +25,6 @@
#define CONST_CS (1<<0) /* Case Sensitive */
#define CONST_PERSISTENT (1<<1) /* Persistent */
#define CONST_EFREE_PERSISTENT (1<<2) /* In conjunction with CONST_PERSISTENT,
* means that the constant should be freed
* using zval_dtor() on shutdown.
*/
typedef struct _zend_constant {
zval value;

View File

@ -43,7 +43,7 @@ static inline void zend_objects_destroy_object(zend_object *object, zend_object_
zend_objects_call_destructor(object, handle TSRMLS_CC);
/* Nuke the object */
zend_hash_destroy(object->properties);
efree(object->properties);
FREE_HASHTABLE(object->properties);
efree(object);
}

View File

@ -138,37 +138,6 @@ ZEND_API int _zval_copy_ctor(zval *zvalue ZEND_FILE_LINE_DC)
}
ZEND_API int zval_persist(zval *zvalue TSRMLS_DC)
{
switch (zvalue->type) {
case IS_OBJECT:
case IS_RESOURCE:
return FAILURE; /* resources and objects cannot be persisted */
break;
case IS_BOOL:
case IS_LONG:
case IS_NULL:
break;
case IS_CONSTANT:
case IS_STRING:
if (zvalue->value.str.val) {
if (zvalue->value.str.len==0) {
zvalue->value.str.val = empty_string;
return SUCCESS;
}
}
persist_alloc(zvalue->value.str.val);
break;
case IS_ARRAY:
case IS_CONSTANT_ARRAY:
persist_alloc(zvalue->value.ht);
zend_hash_apply(zvalue->value.ht, (apply_func_t) zval_persist TSRMLS_CC);
break;
}
return SUCCESS;
}
ZEND_API int zend_print_variable(zval *var)
{
return zend_print_zval(var, 0);

View File

@ -32,8 +32,6 @@ ZEND_API void _zval_ptr_dtor(zval **zval_ptr ZEND_FILE_LINE_DC);
#define zval_dtor(zvalue) _zval_dtor((zvalue) ZEND_FILE_LINE_CC)
#define zval_ptr_dtor(zval_ptr) _zval_ptr_dtor((zval_ptr) ZEND_FILE_LINE_CC)
ZEND_API int zval_persist(zval *zvalue TSRMLS_DC);
#if ZEND_DEBUG
ZEND_API int _zval_copy_ctor_wrapper(zval *zvalue);
ZEND_API void _zval_dtor_wrapper(zval *zvalue);