summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2009-09-01 19:17:58 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2009-09-01 19:17:58 +0200
commit372fec94c50fae821f4e413abd88f84822a2e185 (patch)
tree3d027a9609bca8aa2f51601305726498d6e8cb01 /lib
parent9f3bf020d1772886ef1545c8b1f77f9d44c1533a (diff)
downloadabrt-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')
-rw-r--r--lib/Utils/logging.cpp5
-rw-r--r--lib/Utils/xfuncs.cpp22
2 files changed, 11 insertions, 16 deletions
diff --git a/lib/Utils/logging.cpp b/lib/Utils/logging.cpp
index 58d14ee9..d79ded5d 100644
--- a/lib/Utils/logging.cpp
+++ b/lib/Utils/logging.cpp
@@ -117,3 +117,8 @@ void simple_perror_msg(const char *s)
{
perror_msg("%s", s);
}
+
+void die_out_of_memory(void)
+{
+ error_msg_and_die("Out of memory, exiting");
+}
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.