aboutsummaryrefslogtreecommitdiffhomepage
path: root/util.h
diff options
context:
space:
mode:
authorGravatar axel <axel@liljencrantz.se>2007-01-09 11:35:21 +1000
committerGravatar axel <axel@liljencrantz.se>2007-01-09 11:35:21 +1000
commit76fedccf13d825e8a0740fd6b5049a48d41f191e (patch)
tree005dae98efee8a1f43fe29e19c10e52ce628702f /util.h
parent41206e70b43b6c1b7cfa768d02dc2131c6e4ce8f (diff)
Make it possible to specify an error handler function for out of memory in any of the collection functions. Make the default oom handler print the line where things failed and exit.
darcs-hash:20070109013521-ac50b-dc7304cfb548cf1efc100124125eed032e392169.gz
Diffstat (limited to 'util.h')
-rw-r--r--util.h19
1 files changed, 17 insertions, 2 deletions
diff --git a/util.h b/util.h
index 27f25c0e..c5590c4a 100644
--- a/util.h
+++ b/util.h
@@ -160,7 +160,20 @@ buffer_t;
*/
typedef buffer_t string_buffer_t;
-
+/**
+ Set the out of memory handler callback function. If a memory
+ allocation fails, this function will be called.
+*/
+void (*util_set_oom_handler( void (*h)(void *) ))(void *);
+
+/**
+ This is a possible out of memory handler that will kill the current
+ process in response to any out of memory event, while also printing
+ an error message describing what allocation failed.
+
+ This is the default out of memory handler.
+*/
+void util_die_on_oom( void * );
/**
Returns the larger of two ints
@@ -648,8 +661,10 @@ void b_destroy( buffer_t *b );
/**
Add data of the specified length to the specified buffer_t
+
+ \return 0 on error, non-zero otherwise
*/
-void b_append( buffer_t *b, const void *d, ssize_t len );
+int b_append( buffer_t *b, const void *d, ssize_t len );
/**
Get the current time in microseconds since Jan 1, 1970