mirror of
https://github.com/ipxe/ipxe
synced 2025-12-23 05:21:49 +03:00
Don't always zero memory in malloc(). This saves around 2us on a
full-length PKB allocation.
This commit is contained in:
@@ -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 */
|
||||
|
||||
Reference in New Issue
Block a user