aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2018-11-02 18:48:08 -0700
committerChris Robinson <[email protected]>2018-11-02 18:48:08 -0700
commit5482efc9214d180e1f67fc528f593098ad20a678 (patch)
tree8b5026cc349b46444019fe215fc8b01bf793582f
parenta7dcc1c6d107e5c5401151c50c89e137f2bb0c0b (diff)
Make the polymorphic allocators allocate cleared memory
-rw-r--r--Alc/effects/null.c2
-rw-r--r--Alc/polymorphism.h4
2 files changed, 2 insertions, 4 deletions
diff --git a/Alc/effects/null.c b/Alc/effects/null.c
index 6eaa001f..82ea5d26 100644
--- a/Alc/effects/null.c
+++ b/Alc/effects/null.c
@@ -73,7 +73,7 @@ static ALvoid ALnullState_process(ALnullState* UNUSED(state), ALsizei UNUSED(sam
*/
static void *ALnullState_New(size_t size)
{
- return al_malloc(16, size);
+ return al_calloc(16, size);
}
/* This frees the memory used by the object, after it has been destructed.
diff --git a/Alc/polymorphism.h b/Alc/polymorphism.h
index bc0a5681..83d5585f 100644
--- a/Alc/polymorphism.h
+++ b/Alc/polymorphism.h
@@ -61,7 +61,7 @@ static rettype T1##_##T2##_##func(T2 *obj, argtype1 a, argtype2 b, argtype3 c, a
/* Defines the default functions used to (de)allocate a polymorphic object. */
#define DECLARE_DEFAULT_ALLOCATORS(T) \
-static void* T##_New(size_t size) { return al_malloc(16, size); } \
+static void* T##_New(size_t size) { return al_calloc(16, size); } \
static void T##_Delete(void *ptr) { al_free(ptr); }
@@ -84,14 +84,12 @@ static void T##_Delete(void *ptr) { al_free(ptr); }
_res = (T*)T##_New(sizeof(T)); \
if(_res) \
{ \
- memset(_res, 0, sizeof(T)); \
T##_Construct(_res, EXTRACT_NEW_ARGS
/* Allocate and construct an object, with no arguments. */
#define NEW_OBJ0(_res, T) do { \
_res = (T*)T##_New(sizeof(T)); \
if(_res) \
{ \
- memset(_res, 0, sizeof(T)); \
T##_Construct(_res EXTRACT_NEW_ARGS
/* Destructs and deallocate an object. */