From: Sascha Schumann Date: Fri, 11 May 2001 19:32:01 +0000 (+0000) Subject: Some extensions don't associate any data with hash entries, X-Git-Tag: PRE_GRANULAR_GARBAGE_FIX~481 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3efa08aaa8d253bc90ee75b1b768eeee791e7a75;p=php Some extensions don't associate any data with hash entries, 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). --- diff --git a/Zend/zend_hash.c b/Zend/zend_hash.c index b9a0fae4e1..564ef35d21 100644 --- a/Zend/zend_hash.c +++ b/Zend/zend_hash.c @@ -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) { \