diff options
author | kpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b> | 2006-02-14 22:28:01 +0000 |
---|---|---|
committer | kpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b> | 2006-02-14 22:28:01 +0000 |
commit | e72e24e0470c97ca6a633445a55ccaa20f0db32e (patch) | |
tree | 4034f9af1bd61ecd6709e5d7ec4244fb8dc633b9 /app.c | |
parent | 0993d3ddbf4361d5c28f6552a64f0f203aff8682 (diff) |
more memory allocation wrapper conversion (issue #6365)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@10066 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'app.c')
-rw-r--r-- | app.c | 20 |
1 files changed, 6 insertions, 14 deletions
@@ -425,9 +425,7 @@ int ast_linear_stream(struct ast_channel *chan, const char *filename, int fd, in return -1; } } - lin = malloc(sizeof(struct linear_state)); - if (lin) { - memset(lin, 0, sizeof(lin)); + if ((lin = ast_calloc(1, sizeof(*lin)))) { lin->fd = fd; lin->allowoverride = allowoverride; lin->autoclose = autoclose; @@ -1155,10 +1153,7 @@ enum AST_LOCK_RESULT ast_lock_path(const char *path) int fd; time_t start; - s = alloca(strlen(path) + 10); - fs = alloca(strlen(path) + 20); - - if (!fs || !s) { + if (!(s = alloca(strlen(path) + 10)) || !(fs = alloca(strlen(path) + 20))) { ast_log(LOG_WARNING, "Out of memory!\n"); return AST_LOCK_FAILURE; } @@ -1188,8 +1183,7 @@ enum AST_LOCK_RESULT ast_lock_path(const char *path) int ast_unlock_path(const char *path) { char *s; - s = alloca(strlen(path) + 10); - if (!s) + if (!(s = alloca(strlen(path) + 10))) return -1; snprintf(s, strlen(path) + 9, "%s/%s", path, ".lock"); ast_log(LOG_DEBUG, "Unlocked path '%s'\n", path); @@ -1514,9 +1508,8 @@ char *ast_read_textfile(const char *filename) if (fd < 0) { ast_log(LOG_WARNING, "Cannot open file '%s' for reading: %s\n", filename, strerror(errno)); return NULL; - } - output=(char *)malloc(count); - if (output) { + } + if ((output = ast_malloc(count))) { res = read(fd, output, count - 1); if (res == count - 1) { output[res] = '\0'; @@ -1525,8 +1518,7 @@ char *ast_read_textfile(const char *filename) free(output); output = NULL; } - } else - ast_log(LOG_WARNING, "Out of memory!\n"); + } close(fd); return output; } |