summaryrefslogtreecommitdiff
path: root/main/datastore.c
diff options
context:
space:
mode:
authorKevin P. Fleming <kpfleming@digium.com>2009-05-05 10:34:19 +0000
committerKevin P. Fleming <kpfleming@digium.com>2009-05-05 10:34:19 +0000
commitec5116f80c7ed6922bdc483f11b220ebbee8618b (patch)
treed0b46bfb8216c1ae395bd39991084a219a5e0966 /main/datastore.c
parentd8182202efdc2f292f64718cc038eee982850786 (diff)
Properly account for memory allocated for channels and datastores
As in previous commits, when channels are allocated (with ast_channel_alloc) or datastores are allocated (with ast_datastore_alloc) properly account for the memory being owned by the caller, instead of the allocator function itself. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@192318 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/datastore.c')
-rw-r--r--main/datastore.c29
1 files changed, 25 insertions, 4 deletions
diff --git a/main/datastore.c b/main/datastore.c
index be5479796..3d097860f 100644
--- a/main/datastore.c
+++ b/main/datastore.c
@@ -28,7 +28,8 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/datastore.h"
#include "asterisk/utils.h"
-struct ast_datastore *ast_datastore_alloc(const struct ast_datastore_info *info, const char *uid)
+struct ast_datastore *__ast_datastore_alloc(const struct ast_datastore_info *info, const char *uid,
+ const char *file, int line, const char *function)
{
struct ast_datastore *datastore = NULL;
@@ -37,11 +38,15 @@ struct ast_datastore *ast_datastore_alloc(const struct ast_datastore_info *info,
return NULL;
}
- /* Allocate memory for datastore and clear it */
- datastore = ast_calloc(1, sizeof(*datastore));
- if (!datastore) {
+#if defined(__AST_DEBUG_MALLOC)
+ if (!(datastore = __ast_calloc(1, sizeof(*datastore), file, line, function))) {
+ return NULL;
+ }
+#else
+ if (!(datastore = ast_calloc(1, sizeof(*datastore)))) {
return NULL;
}
+#endif
datastore->info = info;
@@ -71,3 +76,19 @@ int ast_datastore_free(struct ast_datastore *datastore)
return res;
}
+
+/* DO NOT PUT ADDITIONAL FUNCTIONS BELOW THIS BOUNDARY
+ *
+ * ONLY FUNCTIONS FOR PROVIDING BACKWARDS ABI COMPATIBILITY BELONG HERE
+ *
+ */
+
+/* Provide binary compatibility for modules that call ast_datastore_alloc() directly;
+ * newly compiled modules will call __ast_datastore_alloc() via the macros in datastore.h
+ */
+#undef ast_datastore_alloc
+struct ast_datastore *ast_datastore_alloc(const struct ast_datastore_info *info, const char *uid);
+struct ast_datastore *ast_datastore_alloc(const struct ast_datastore_info *info, const char *uid)
+{
+ return __ast_datastore_alloc(info, uid, __FILE__, __LINE__, __FUNCTION__);
+}