diff options
author | kpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b> | 2009-05-05 13:00:04 +0000 |
---|---|---|
committer | kpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b> | 2009-05-05 13:00:04 +0000 |
commit | 12f6b763d206e5a57e07f45eabd90c7f8c61fd49 (patch) | |
tree | d3359456f178cd1af1e2b160bf2674b9334b95f8 /main/datastore.c | |
parent | a01063165d8e8500f6a55f4abafe5e52f72e7596 (diff) |
Merged revisions 192318 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk
........
r192318 | kpfleming | 2009-05-05 12:34:19 +0200 (Tue, 05 May 2009) | 5 lines
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: http://svn.digium.com/svn/asterisk/branches/1.6.2@192355 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main/datastore.c')
-rw-r--r-- | main/datastore.c | 29 |
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__); +} |