summaryrefslogtreecommitdiff
path: root/Zend/zend_list.c
diff options
context:
space:
mode:
authorZeev Suraski <zeev@php.net>2001-03-28 15:22:15 +0000
committerZeev Suraski <zeev@php.net>2001-03-28 15:22:15 +0000
commit3d3d8881c6061739b8687f4e635670c0d78ab0e1 (patch)
treebb2e12428ca5a87d13928cf34aa3bc128c2964e8 /Zend/zend_list.c
parent8c13f9d56f4458a9ee49139837e55a793e474606 (diff)
downloadphp-git-3d3d8881c6061739b8687f4e635670c0d78ab0e1.tar.gz
Cleaner way of making sure resources start at 1 and not 0...
Diffstat (limited to 'Zend/zend_list.c')
-rw-r--r--Zend/zend_list.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/Zend/zend_list.c b/Zend/zend_list.c
index 29a8abc990..fbdd774367 100644
--- a/Zend/zend_list.c
+++ b/Zend/zend_list.c
@@ -36,13 +36,11 @@ static inline int zend_list_do_insert(HashTable *list, void *ptr, int type)
int index;
zend_rsrc_list_entry le;
- index = zend_hash_next_free_element(list);
-
- if (index==0) index++;
-
le.ptr=ptr;
le.type=type;
le.refcount=1;
+
+ index = zend_hash_next_free_element(list);
zend_hash_index_update(list, index, (void *) &le, sizeof(zend_rsrc_list_entry), NULL);
return index;
}
@@ -238,7 +236,9 @@ void plist_entry_destructor(void *ptr)
int zend_init_rsrc_list(ELS_D)
{
- return zend_hash_init(&EG(regular_list), 0, NULL, list_entry_destructor, 0);
+ if (zend_hash_init(&EG(regular_list), 0, NULL, list_entry_destructor, 0)==SUCCESS) {
+ EG(regular_list).nNextFreeElement=1; /* we don't want resource id 0 */
+ }
}