From 3e0286dee3ae01047666f4944d304dbbee2e58a5 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Sat, 2 Dec 2006 20:10:21 +0000 Subject: Move ANSI C standard prototypes to stdlib.h; leave the gPXE-specific function prototypes (e.g. malloc_dma()) in malloc.h. --- src/include/stdlib.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src/include/stdlib.h') diff --git a/src/include/stdlib.h b/src/include/stdlib.h index 4dd7e54..a7dd1d8 100644 --- a/src/include/stdlib.h +++ b/src/include/stdlib.h @@ -2,5 +2,25 @@ #define STDLIB_H extern unsigned long strtoul ( const char *p, char **endp, int base ); +extern void * realloc ( void *old_ptr, size_t new_size ); +extern void * malloc ( size_t size ); +extern void free ( void *ptr ); + +/** + * Allocate cleared memory + * + * @v nmemb Number of members + * @v size Size of each member + * @ret ptr Allocated memory + * + * Allocate memory as per malloc(), and zero it. + * + * Note that malloc() and calloc() are identical, in the interests of + * reducing code size. Callers should not, however, rely on malloc() + * clearing memory, since this behaviour may change in future. + */ +static inline void * calloc ( size_t nmemb, size_t size ) { + return malloc ( nmemb * size ); +} #endif /* STDLIB_H */ -- cgit v1.1