From 66ed074cc4e85dbd76483f09e6fec4ae3dc0eccb Mon Sep 17 00:00:00 2001 From: Victor Seva Date: Fri, 28 Dec 2018 15:59:58 +0100 Subject: [PATCH] app_python: use mem error macros --- src/modules/app_python/apy_kemi.c | 2 +- src/modules/app_python/python_support.c | 12 ++++-------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/modules/app_python/apy_kemi.c b/src/modules/app_python/apy_kemi.c index bcccbaa2614..87e2ccce07a 100644 --- a/src/modules/app_python/apy_kemi.c +++ b/src/modules/app_python/apy_kemi.c @@ -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; diff --git a/src/modules/app_python/python_support.c b/src/modules/app_python/python_support.c index 7b1a93017ea..7c4522eba6d 100644 --- a/src/modules/app_python/python_support.c +++ b/src/modules/app_python/python_support.c @@ -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; } @@ -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); @@ -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)); @@ -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;