diff options
author | Tavian Barnes <tavianator@gmail.com> | 2010-11-14 21:20:43 -0500 |
---|---|---|
committer | Tavian Barnes <tavianator@gmail.com> | 2010-11-14 21:20:43 -0500 |
commit | 8fe33a340b8979a73fa84f201c15519a9b5d0266 (patch) | |
tree | 12cdbb1c1b9a48f533ab36980602785be1e1deeb /libdimension/dimension/malloc.h | |
parent | 20a55aa78050d94b187d4edfaac91ea00efea505 (diff) | |
download | dimension-8fe33a340b8979a73fa84f201c15519a9b5d0266.tar.xz |
Document libdimension with Doxygen.
Diffstat (limited to 'libdimension/dimension/malloc.h')
-rw-r--r-- | libdimension/dimension/malloc.h | 36 |
1 files changed, 31 insertions, 5 deletions
diff --git a/libdimension/dimension/malloc.h b/libdimension/dimension/malloc.h index 3c9e84b..7a5295a 100644 --- a/libdimension/dimension/malloc.h +++ b/libdimension/dimension/malloc.h @@ -18,15 +18,41 @@ * <http://www.gnu.org/licenses/>. * *************************************************************************/ -/* - * Seriously, how often does malloc fail? And how often can you do something - * better than bail out when it does? dmnsn_malloc() is like malloc in every - * way except it calls dmnsn_error() on failure. +/** + * @file + * Dynamic memory. dmnsn_malloc() and friends behave like their + * non-dmnsn_-prefixed counterparts, but never return NULL. If allocation + * fails, they instead call dmnsn_error(DMNSN_SEVERITY_HIGH). */ #include <stddef.h> /* For size_t */ +/** + * Allocate some memory. Always use dmnsn_free() to free this memory, never + * free(). + * @param[in] size The size of the memory block to allocate. + * @return The allocated memory area. + */ void *dmnsn_malloc(size_t size); + +/** + * Expand or shrink an allocation created by dmnsn_malloc(). + * @param[in] ptr The block to resize. + * @param[in] size The new size. + * @return The resized memory area. + */ void *dmnsn_realloc(void *ptr, size_t size); + +/** + * Duplicate a string. + * @param[in] s The string to duplicate. + * @return A string with the same contents as \p s, suitable for release by + * dmnsn_free(). + */ char *dmnsn_strdup(const char *s); -void dmnsn_free(void *ptr); + +/** + * Free memory allocated by dmnsn_malloc() or dmnsn_strdup(). + * @param[in] ptr The memory block to free, or NULL. + */ +void dmnsn_free(void *ptr); |