diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2018-09-13 14:50:08 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2018-10-04 08:02:29 +0200 |
commit | 313f897f10fcf56ad21e7a07f7d70106dccbc188 (patch) | |
tree | f129d9f74a42c7784f88c363ff0dc28f31f254cb /cpukit/libcsupport | |
parent | 1ad43f8809882b9a281a4f7c8fe232e87ea4371f (diff) |
Optimize calloc()
Use return value of memset() to enable tail call optimizations.
Diffstat (limited to 'cpukit/libcsupport')
-rw-r--r-- | cpukit/libcsupport/src/calloc.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/cpukit/libcsupport/src/calloc.c b/cpukit/libcsupport/src/calloc.c index 20db533786..78b08ab5a5 100644 --- a/cpukit/libcsupport/src/calloc.c +++ b/cpukit/libcsupport/src/calloc.c @@ -28,15 +28,16 @@ void *calloc( size_t elsize ) { - char *cptr; + void *cptr; size_t length; length = nelem * elsize; cptr = malloc( length ); RTEMS_OBFUSCATE_VARIABLE( cptr ); - if ( cptr ) - memset( cptr, '\0', length ); + if ( RTEMS_PREDICT_FALSE( cptr == NULL ) ) { + return cptr; + } - return cptr; + return memset( cptr, 0, length ); } #endif |