mirror of
https://github.com/jemalloc/jemalloc.git
synced 2026-07-16 05:37:18 +03:00
Avoid NULL check in free() and malloc_usable_size().
Generalize isalloc() to handle NULL pointers in such a way that the NULL checking overhead is only paid when introspecting huge allocations (or NULL). This allows free() and malloc_usable_size() to no longer check for NULL. Submitted by Igor Bukanov and Mike Hommey.
This commit is contained in:
parent
80b25932ca
commit
96d4120ac0
5 changed files with 37 additions and 22 deletions
19
test/null.c
Normal file
19
test/null.c
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
|
||||
#define JEMALLOC_MANGLE
|
||||
#include "jemalloc_test.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
|
||||
fprintf(stderr, "Test begin\n");
|
||||
|
||||
free(malloc(1));
|
||||
free(NULL);
|
||||
assert(malloc_usable_size(NULL) == 0);
|
||||
|
||||
fprintf(stderr, "Test end\n");
|
||||
return (0);
|
||||
}
|
||||
2
test/null.exp
Normal file
2
test/null.exp
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
Test begin
|
||||
Test end
|
||||
Loading…
Add table
Add a link
Reference in a new issue