summaryrefslogtreecommitdiffstats
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
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>
-rw-r--r--inc/abrtlib.h2
-rw-r--r--lib/Utils/logging.cpp5
-rw-r--r--lib/Utils/xfuncs.cpp22
-rw-r--r--src/Daemon/CommLayerServerDBus.cpp6
4 files changed, 12 insertions, 23 deletions
diff --git a/inc/abrtlib.h b/inc/abrtlib.h
index 4f0244e8..58ec0040 100644
--- a/inc/abrtlib.h
+++ b/inc/abrtlib.h
@@ -63,6 +63,7 @@ extern const char *msg_eol;
extern int logmode;
extern int xfunc_error_retval;
extern void xfunc_die(void) NORETURN;
+extern void die_out_of_memory(void) NORETURN;
extern void error_msg(const char *s, ...) __attribute__ ((format (printf, 1, 2)));
extern void error_msg_and_die(const char *s, ...) __attribute__ ((noreturn, format (printf, 1, 2)));
extern void perror_msg(const char *s, ...) __attribute__ ((format (printf, 1, 2)));
@@ -82,7 +83,6 @@ extern void verror_msg(const char *s, va_list p, const char *strerr);
#undef log
#define log(...) error_msg(__VA_ARGS__)
-void* malloc_or_warn(size_t size);
void* xmalloc(size_t size);
void* xrealloc(void *ptr, size_t size);
void* xzalloc(size_t size);
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.
diff --git a/src/Daemon/CommLayerServerDBus.cpp b/src/Daemon/CommLayerServerDBus.cpp
index fb725bb9..0a1e6f0e 100644
--- a/src/Daemon/CommLayerServerDBus.cpp
+++ b/src/Daemon/CommLayerServerDBus.cpp
@@ -7,12 +7,6 @@
#include "CommLayerServerDBus.h"
-static void die_out_of_memory()
-{
- error_msg_and_die("Out of memory, exiting");
-}
-
-
static DBusConnection* s_pConn;