Merge pull request #4696 from oranagra/zrealloc_fix

Fix zrealloc to behave similarly to je_realloc when size is 0
This commit is contained in:
Salvatore Sanfilippo 2019-03-21 12:18:04 +01:00 committed by GitHub
commit 5c47e2e964
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -148,6 +148,10 @@ void *zrealloc(void *ptr, size_t size) {
size_t oldsize;
void *newptr;
if (size == 0 && ptr!=NULL) {
zfree(ptr);
return NULL;
}
if (ptr == NULL) return zmalloc(size);
#ifdef HAVE_MALLOC_SIZE
oldsize = zmalloc_size(ptr);