From ef98e35c9c44148611aa2c23325431d19405c781 Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Tue, 6 May 2014 21:23:55 -0400 Subject: malloc: New DMNSN_MALLOC() macro to save a sizeof(). --- libdimension/dimension/malloc.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'libdimension/dimension') diff --git a/libdimension/dimension/malloc.h b/libdimension/dimension/malloc.h index 4151800..742e3a2 100644 --- a/libdimension/dimension/malloc.h +++ b/libdimension/dimension/malloc.h @@ -1,5 +1,5 @@ /************************************************************************* - * Copyright (C) 2010-2011 Tavian Barnes * + * Copyright (C) 2010-2014 Tavian Barnes * * * * This file is part of The Dimension Library. * * * @@ -35,6 +35,14 @@ */ void *dmnsn_malloc(size_t size); +/** + * Allocate some memory. Always use dmnsn_free() to free this memory, never + * free(). + * @param[in] type The type of the memory block to allocate. + * @return The allocated memory area. + */ +#define DMNSN_MALLOC(type) ((type *)dmnsn_malloc(sizeof(type))) + /** * Expand or shrink an allocation created by dmnsn_malloc(). * @param[in] ptr The block to resize. -- cgit v1.2.3