Permalink
Browse files

Implement zend_hash_add_empty_element() using the existing infrastruc…

…ture
  • Loading branch information...
1 parent 4c0d85b commit 755207a1e63161a0ef625299fed9a2d569357f7a @zsuraski zsuraski committed May 16, 2001
Showing with 11 additions and 8 deletions.
  1. +9 −8 Zend/zend_hash.c
  2. +2 −0 Zend/zend_hash.h
View
@@ -153,11 +153,6 @@ ZEND_API ulong hashpjw(char *arKey, uint nKeyLength)
} \
memcpy(&(p)->pDataPtr, pData, sizeof(void *)); \
(p)->pData = &(p)->pDataPtr; \
- } else if (nDataSize == 0) { \
- if (!(p)->pDataPtr) { \
- pefree((p)->pData, (ht)->persistent); \
- } \
- (p)->pData = &(p)->pDataPtr; \
} else { \
if ((p)->pDataPtr) { \
(p)->pData = (void *) pemalloc(nDataSize, (ht)->persistent); \
@@ -170,9 +165,6 @@ ZEND_API ulong hashpjw(char *arKey, uint nKeyLength)
if (nDataSize == sizeof(void*)) { \
memcpy(&(p)->pDataPtr, pData, sizeof(void *)); \
(p)->pData = &(p)->pDataPtr; \
- } else if (nDataSize == 0) { \
- (p)->pDataPtr = (void *) 1; \
- (p)->pData = &(p)->pDataPtr; \
} else { \
(p)->pData = (void *) pemalloc(nDataSize, (ht)->persistent); \
if (!(p)->pData) { \
@@ -387,6 +379,14 @@ ZEND_API int zend_hash_quick_add_or_update(HashTable *ht, char *arKey, uint nKey
}
+ZEND_API int zend_hash_add_empty_element(HashTable *ht, char *arKey, uint nKeyLength)
+{
+ void *dummy=NULL;
+
+ return zend_hash_add(ht, arKey, nKeyLength, &dummy, sizeof(void *), NULL);
+}
+
+
ZEND_API int zend_hash_index_update_or_next_insert(HashTable *ht, ulong h, void *pData, uint nDataSize, void **pDest, int flag)
{
uint nIndex;
@@ -1244,6 +1244,7 @@ ZEND_API ulong zend_hash_next_free_element(HashTable *ht)
}
+
#if ZEND_DEBUG
void zend_hash_display_pListTail(HashTable *ht)
{
View
@@ -104,6 +104,8 @@ ZEND_API int zend_hash_index_update_or_next_insert(HashTable *ht, ulong h, void
#define zend_hash_next_index_insert(ht,pData,nDataSize,pDest) \
zend_hash_index_update_or_next_insert(ht,0,pData,nDataSize,pDest,HASH_NEXT_INSERT)
+ZEND_API int zend_hash_add_empty_element(HashTable *ht, char *arKey, uint nKeyLength);
+
typedef struct _zend_hash_key {
char *arKey;
uint nKeyLength;

0 comments on commit 755207a

Please sign in to comment.