diff options
author | Dana Robinson <43805+derobins@users.noreply.github.com> | 2023-08-25 20:56:50 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-25 20:56:50 (GMT) |
commit | 627f7c5e026a55f176d8dfcab51633cf3b704ce6 (patch) | |
tree | b8ef6ca645521104c25a7b5538259bb449d51c58 /src/H5MM.c | |
parent | 3dd60d914e762c6cf7d99646bc516015229176cd (diff) | |
download | hdf5-627f7c5e026a55f176d8dfcab51633cf3b704ce6.zip hdf5-627f7c5e026a55f176d8dfcab51633cf3b704ce6.tar.gz hdf5-627f7c5e026a55f176d8dfcab51633cf3b704ce6.tar.bz2 |
Convert some H5MM calls to standard C equivalents (#2382)
* H5MM_calloc and malloc are now mapped to stdlib C calls
* H5MM_memcpy now maps directly to memcpy in release builds
* H5MM_memcpy is still implemented as a separate function that
checks for buffer overlap when H5MM_DEBUG is defined
(default w/ debug builds)
* Switches many library memcpy calls to use H5MM_memcpy
* Fixes a possible zero allocation in H5Olayout.c
Diffstat (limited to 'src/H5MM.c')
-rw-r--r-- | src/H5MM.c | 61 |
1 files changed, 4 insertions, 57 deletions
@@ -55,63 +55,6 @@ /*******************/ /*------------------------------------------------------------------------- - * Function: H5MM_malloc - * - * Purpose: Similar to the C89 version of malloc(). - * - * On size of 0, we return a NULL pointer instead of the - * standard-allowed 'special' pointer since that's more - * difficult to check as a return value. This is still - * considered an error condition since allocations of zero - * bytes usually indicate problems. - * - * Return: Success: Pointer to new memory - * Failure: NULL - *------------------------------------------------------------------------- - */ -void * -H5MM_malloc(size_t size) -{ - void *ret_value = NULL; - - /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */ - FUNC_ENTER_NOAPI_NOINIT_NOERR - - ret_value = malloc(size); - - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5MM_malloc() */ - -/*------------------------------------------------------------------------- - * Function: H5MM_calloc - * - * Purpose: Similar to the C89 version of calloc(), except this - * routine just takes a 'size' parameter. - * - * On size of 0, we return a NULL pointer instead of the - * standard-allowed 'special' pointer since that's more - * difficult to check as a return value. This is still - * considered an error condition since allocations of zero - * bytes usually indicate problems. - * - * Return: Success: Pointer to new memory - * Failure: NULL - *------------------------------------------------------------------------- - */ -void * -H5MM_calloc(size_t size) -{ - void *ret_value = NULL; - - /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */ - FUNC_ENTER_NOAPI_NOINIT_NOERR - - ret_value = calloc(1, size); - - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5MM_calloc() */ - -/*------------------------------------------------------------------------- * Function: H5MM_realloc * * Purpose: Similar semantics as C89's realloc(). Specifically, the @@ -283,6 +226,8 @@ H5MM_xfree_const(const void *mem) FUNC_LEAVE_NOAPI(NULL) } /* end H5MM_xfree_const() */ +#ifdef H5MM_DEBUG + /*------------------------------------------------------------------------- * Function: H5MM_memcpy * @@ -313,3 +258,5 @@ H5MM_memcpy(void *dest, const void *src, size_t n) FUNC_LEAVE_NOAPI(ret) } /* end H5MM_memcpy() */ + +#endif /* H5MM_DEBUG */ |