summaryrefslogtreecommitdiffstats
path: root/dbus/dbus-memory.c
diff options
context:
space:
mode:
authorHavoc Pennington <hp@redhat.com>2003-02-14 04:54:55 +0000
committerHavoc Pennington <hp@redhat.com>2003-02-14 04:54:55 +0000
commit07a795f1db3b09beeec647643a4f263f617bc371 (patch)
tree4f557fce8ee2012dc7fcd40587d8d40b20d112e3 /dbus/dbus-memory.c
parentb544e59358251f0811c9fe35c149a67d5deafdba (diff)
2003-02-14 Havoc Pennington <hp@pobox.com>
* dbus/dbus-mempool.c: fail if the debug functions so indicate * dbus/dbus-memory.c: fail if the debug functions indicate we should * dbus/dbus-internals.c (_dbus_set_fail_alloc_counter) (_dbus_decrement_fail_alloc_counter): debug functions to simulate memory allocation failures
Diffstat (limited to 'dbus/dbus-memory.c')
-rw-r--r--dbus/dbus-memory.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/dbus/dbus-memory.c b/dbus/dbus-memory.c
index 52a563e9..357e8be6 100644
--- a/dbus/dbus-memory.c
+++ b/dbus/dbus-memory.c
@@ -1,7 +1,7 @@
/* -*- mode: C; c-file-style: "gnu" -*- */
/* dbus-memory.c D-BUS memory handling
*
- * Copyright (C) 2002 Red Hat Inc.
+ * Copyright (C) 2002, 2003 Red Hat Inc.
*
* Licensed under the Academic Free License version 1.2
*
@@ -22,6 +22,7 @@
*/
#include "dbus-memory.h"
+#include "dbus-internals.h"
#include <stdlib.h>
/**
@@ -82,6 +83,9 @@
void*
dbus_malloc (size_t bytes)
{
+ if (_dbus_decrement_fail_alloc_counter ())
+ return NULL;
+
if (bytes == 0) /* some system mallocs handle this, some don't */
return NULL;
else
@@ -100,6 +104,9 @@ dbus_malloc (size_t bytes)
void*
dbus_malloc0 (size_t bytes)
{
+ if (_dbus_decrement_fail_alloc_counter ())
+ return NULL;
+
if (bytes == 0)
return NULL;
else
@@ -120,6 +127,9 @@ void*
dbus_realloc (void *memory,
size_t bytes)
{
+ if (_dbus_decrement_fail_alloc_counter ())
+ return NULL;
+
if (bytes == 0) /* guarantee this is safe */
{
dbus_free (memory);