summaryrefslogtreecommitdiffstats
path: root/src/include/stdlib.h
diff options
context:
space:
mode:
authorMichael Brown2007-01-18 13:54:18 +0100
committerMichael Brown2007-01-18 13:54:18 +0100
commit35776f481c02caa700369db0e884bd9f7c7d3c0e (patch)
tree1deb52c624ab9bf9c56f5c26520d198a29e228f0 /src/include/stdlib.h
parentSwitch from calloc() to malloc()+memset() to match the practices used (diff)
downloadipxe-35776f481c02caa700369db0e884bd9f7c7d3c0e.tar.gz
ipxe-35776f481c02caa700369db0e884bd9f7c7d3c0e.tar.xz
ipxe-35776f481c02caa700369db0e884bd9f7c7d3c0e.zip
Don't always zero memory in malloc(). This saves around 2us on a
full-length PKB allocation.
Diffstat (limited to 'src/include/stdlib.h')
-rw-r--r--src/include/stdlib.h10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/include/stdlib.h b/src/include/stdlib.h
index 2b6471e1..39ad831f 100644
--- a/src/include/stdlib.h
+++ b/src/include/stdlib.h
@@ -8,6 +8,8 @@ extern void free ( void *ptr );
extern int system ( const char *command );
extern long int random ( void );
+extern void * _calloc ( size_t len );
+
/**
* Allocate cleared memory
*
@@ -17,12 +19,12 @@ extern long int random ( void );
*
* 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.
+ * This is implemented as a static inline, with the body of the
+ * function in _calloc(), since in most cases @c nmemb will be 1 and
+ * doing the multiply is just wasteful.
*/
static inline void * calloc ( size_t nmemb, size_t size ) {
- return malloc ( nmemb * size );
+ return _calloc ( nmemb * size );
}
#endif /* STDLIB_H */