Skip to content

Commit

Permalink
app_python: use mem error macros
Browse files Browse the repository at this point in the history
  • Loading branch information
linuxmaniac committed Dec 28, 2018
1 parent bfe9fed commit 66ed074
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/modules/app_python/apy_kemi.c
Expand Up @@ -1342,7 +1342,7 @@ int apy_sr_init_mod(void)
if(_sr_python_reload_version == NULL) {
_sr_python_reload_version = (int*)shm_malloc(sizeof(int));
if(_sr_python_reload_version == NULL) {
LM_ERR("failed to allocated reload version\n");
SHM_MEM_ERROR;
return -1;
}
*_sr_python_reload_version = 0;
Expand Down
12 changes: 4 additions & 8 deletions src/modules/app_python/python_support.c
Expand Up @@ -94,8 +94,7 @@ void python_handle_exception(const char *fmt, ...)
buf = (char *)pkg_realloc(NULL, buflen * sizeof(char));
if (!buf)
{
LM_ERR("Can't allocate memory (%lu bytes), pkg_realloc() has failed."
" Not enough memory.\n", (unsigned long)(buflen * sizeof(char *)));
PKG_MEM_ERROR;
if (srcbuf) pkg_free(srcbuf);
return;
}
Expand Down Expand Up @@ -130,8 +129,7 @@ void python_handle_exception(const char *fmt, ...)
buf = (char *)pkg_reallocxf(buf, buflen * sizeof(char));
if (!buf)
{
LM_ERR("Can't allocate memory (%lu bytes), pkg_realloc() has failed."
" Not enough memory.\n", (unsigned long)(buflen * sizeof(char *)));
PKG_MEM_ERROR;
Py_DECREF(line);
Py_DECREF(pResult);
if (srcbuf) pkg_free(srcbuf);
Expand Down Expand Up @@ -200,8 +198,7 @@ static char *make_message(const char *fmt, va_list ap)
p = (char *)pkg_realloc(NULL, size * sizeof(char));
if (!p)
{
LM_ERR("Can't allocate memory (%lu bytes), pkg_malloc() has failed:"
" Not enough memory.\n", (unsigned long)(size * sizeof(char)));
PKG_MEM_ERROR;
return NULL;
}
memset(p, 0, size * sizeof(char));
Expand All @@ -221,8 +218,7 @@ static char *make_message(const char *fmt, va_list ap)
np = (char *)pkg_realloc(p, size * sizeof(char));
if (!np)
{
LM_ERR("Can't allocate memory (%lu bytes), pkg_realloc() has failed:"
" Not enough memory.\n", (unsigned long)size * sizeof(char));
PKG_MEM_ERROR;
if (p)
pkg_free(p);
return NULL;
Expand Down

0 comments on commit 66ed074

Please sign in to comment.