]> granicus.if.org Git - php/commitdiff
Some extensions don't associate any data with hash entries,
authorSascha Schumann <sas@php.net>
Fri, 11 May 2001 19:32:01 +0000 (19:32 +0000)
committerSascha Schumann <sas@php.net>
Fri, 11 May 2001 19:32:01 +0000 (19:32 +0000)
except the key.  Prior to this change, a separate chunk of memory
was allocated in that case to store exactly zero bytes (plus
memory manager overhead).  We treat that case similar to the
pointer case, but don't copy any data at all (because the pointer
is usually the NULL pointer).

Zend/zend_hash.c

index b9a0fae4e1bd12d2b5324a7e94607a2d17ae5e3a..564ef35d21395a058315690d9cc1e83b4d57ab46 100644 (file)
@@ -153,6 +153,11 @@ 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);    \
@@ -165,6 +170,8 @@ 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)->pData = &(p)->pDataPtr;                                                                    \
        } else {                                                                                                                        \
                (p)->pData = (void *) pemalloc(nDataSize, (ht)->persistent);    \
                if (!(p)->pData) {                                                                                              \