diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2009-09-01 19:17:58 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2009-09-01 19:17:58 +0200 |
commit | 372fec94c50fae821f4e413abd88f84822a2e185 (patch) | |
tree | 3d027a9609bca8aa2f51601305726498d6e8cb01 /lib/Utils/xfuncs.cpp | |
parent | 9f3bf020d1772886ef1545c8b1f77f9d44c1533a (diff) | |
download | abrt-372fec94c50fae821f4e413abd88f84822a2e185.tar.gz abrt-372fec94c50fae821f4e413abd88f84822a2e185.tar.xz abrt-372fec94c50fae821f4e413abd88f84822a2e185.zip |
move die_out_of_memory() to abrtlib
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'lib/Utils/xfuncs.cpp')
-rw-r--r-- | lib/Utils/xfuncs.cpp | 22 |
1 files changed, 6 insertions, 16 deletions
diff --git a/lib/Utils/xfuncs.cpp b/lib/Utils/xfuncs.cpp index cc147204..01196065 100644 --- a/lib/Utils/xfuncs.cpp +++ b/lib/Utils/xfuncs.cpp @@ -5,22 +5,12 @@ */ #include "abrtlib.h" -static const char msg_memory_exhausted[] = "memory exhausted"; - -void* malloc_or_warn(size_t size) -{ - void *ptr = malloc(size); - if (ptr == NULL && size != 0) - error_msg(msg_memory_exhausted); - return ptr; -} - // Die if we can't allocate size bytes of memory. void* xmalloc(size_t size) { void *ptr = malloc(size); if (ptr == NULL && size != 0) - error_msg_and_die(msg_memory_exhausted); + die_out_of_memory(); return ptr; } @@ -31,7 +21,7 @@ void* xrealloc(void *ptr, size_t size) { ptr = realloc(ptr, size); if (ptr == NULL && size != 0) - error_msg_and_die(msg_memory_exhausted); + die_out_of_memory(); return ptr; } @@ -54,7 +44,7 @@ char* xstrdup(const char *s) t = strdup(s); if (t == NULL) - error_msg_and_die(msg_memory_exhausted); + die_out_of_memory(); return t; } @@ -160,7 +150,7 @@ char* xasprintf(const char *format, ...) #endif if (r < 0) - error_msg_and_die(msg_memory_exhausted); + die_out_of_memory(); return string_ptr; } @@ -187,7 +177,7 @@ std::string ssprintf(const char *format, ...) #endif if (r < 0) - error_msg_and_die(msg_memory_exhausted); + die_out_of_memory(); std::string res = string_ptr; free(string_ptr); return res; @@ -196,7 +186,7 @@ std::string ssprintf(const char *format, ...) void xsetenv(const char *key, const char *value) { if (setenv(key, value, 1)) - error_msg_and_die(msg_memory_exhausted); + die_out_of_memory(); } // Die with an error message if we can't open a new socket. |