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/H5MMprivate.h | |
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/H5MMprivate.h')
-rw-r--r-- | src/H5MMprivate.h | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/src/H5MMprivate.h b/src/H5MMprivate.h index f94a433..39bba2c 100644 --- a/src/H5MMprivate.h +++ b/src/H5MMprivate.h @@ -14,7 +14,7 @@ * * Created: H5MMprivate.h * - * Purpose: Private header for memory management. + * Purpose: Private header for memory management * *------------------------------------------------------------------------- */ @@ -26,19 +26,33 @@ /* Private headers needed by this file */ #include "H5private.h" -#define H5MM_free(Z) free(Z) +/* Uncomment this macro to enable some extra memory checks + * + * This can also be defined at configure time, which we do in debug builds + * by default. + */ +/* #define H5MM_DEBUG */ + +#define H5MM_calloc(Z) calloc(1, Z) +#define H5MM_free(Z) free(Z) +#define H5MM_malloc(Z) malloc(Z) + +#ifndef H5MM_DEBUG +#define H5MM_memcpy(D, S, N) memcpy(D, S, N) +#endif /* !H5MM_DEBUG */ /* * Library prototypes... */ -H5_DLL void *H5MM_malloc(size_t size) H5_ATTR_MALLOC; -H5_DLL void *H5MM_calloc(size_t size) H5_ATTR_MALLOC; H5_DLL void *H5MM_realloc(void *mem, size_t size); H5_DLL char *H5MM_xstrdup(const char *s) H5_ATTR_MALLOC; H5_DLL char *H5MM_strdup(const char *s) H5_ATTR_MALLOC; H5_DLL char *H5MM_strndup(const char *s, size_t n) H5_ATTR_MALLOC; H5_DLL void *H5MM_xfree(void *mem); H5_DLL void *H5MM_xfree_const(const void *mem); + +#ifdef H5MM_DEBUG H5_DLL void *H5MM_memcpy(void *dest, const void *src, size_t n); +#endif #endif /* H5MMprivate_H */ |