Skip to content

Commit

Permalink
Revert "unix,win: handle zero-sized allocations uniformly"
Browse files Browse the repository at this point in the history
This reverts commit ba78023.
Inconsistently working is better than consistently broken
(until the issues this creates can be fixed with libuv).
Refs: libuv#2076

(cherry picked from commit 7273f6c)
(cherry picked from commit 3071fe1)
  • Loading branch information
vtjnash committed Feb 9, 2024
1 parent 29a708a commit fa32ef5
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions src/uv-common.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,7 @@ char* uv__strndup(const char* s, size_t n) {
}

void* uv__malloc(size_t size) {
if (size > 0)
return uv__allocator.local_malloc(size);
return NULL;
return uv__allocator.local_malloc(size);
}

void uv__free(void* ptr) {
Expand All @@ -94,10 +92,7 @@ void* uv__calloc(size_t count, size_t size) {
}

void* uv__realloc(void* ptr, size_t size) {
if (size > 0)
return uv__allocator.local_realloc(ptr, size);
uv__free(ptr);
return NULL;
return uv__allocator.local_realloc(ptr, size);
}

void* uv__reallocf(void* ptr, size_t size) {
Expand Down

0 comments on commit fa32ef5

Please sign in to comment.