File tree Expand file tree Collapse file tree 3 files changed +17
-13
lines changed Expand file tree Collapse file tree 3 files changed +17
-13
lines changed Original file line number Diff line number Diff line change 1
1
2
2
ALL = libmallocng.a libmallocng.so
3
- SRCS = malloc.c free.c realloc.c aligned_alloc.c posix_memalign.c memalign.c malloc_usable_size.c dump.c
3
+ SRCS = malloc.c calloc.c free.c realloc.c aligned_alloc.c posix_memalign.c memalign.c malloc_usable_size.c dump.c
4
4
OBJS = $(SRCS:.c=.o )
5
5
CFLAGS = -fPIC -Wall -O2 -ffreestanding
6
6
Original file line number Diff line number Diff line change
1
+ #include <stdlib.h>
2
+ #include <string.h>
3
+ #include <errno.h>
4
+ #include "meta.h"
5
+
6
+ void * calloc (size_t m , size_t n )
7
+ {
8
+ if (n && m > (size_t )-1 /n ) {
9
+ errno = ENOMEM ;
10
+ return 0 ;
11
+ }
12
+ n *= m ;
13
+ void * p = malloc (n );
14
+ if (!p ) return p ;
15
+ return n >= MMAP_THRESHOLD ? p : memset (p , 0 , n );
16
+ }
Original file line number Diff line number Diff line change @@ -378,15 +378,3 @@ void *malloc(size_t n)
378
378
unlock ();
379
379
return enframe (g , idx , n , ctr );
380
380
}
381
-
382
- void * calloc (size_t m , size_t n )
383
- {
384
- if (n && m > (size_t )-1 /n ) {
385
- errno = ENOMEM ;
386
- return 0 ;
387
- }
388
- n *= m ;
389
- void * p = malloc (n );
390
- if (!p ) return p ;
391
- return n >= MMAP_THRESHOLD ? p : memset (p , 0 , n );
392
- }
You can’t perform that action at this time.
0 commit comments