[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: make 'list' and 'oset' modules usable in libraries
From: |
jemarch |
Subject: |
Re: make 'list' and 'oset' modules usable in libraries |
Date: |
Wed, 16 Dec 2009 21:05:23 +0100 |
User-agent: |
Wanderlust/2.14.0 (Africa) SEMI/1.14.6 (Maruoka) FLIM/1.14.8 (Shijō) APEL/10.6 Emacs/23.0.92 (i686-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) |
Hi Bruno.
José Marchesi reported that the 'list' and 'oset' container data structures
are not really usable in libraries, because they call xalloc_die() when
an out-of-memory condition occurs. An xalloc_die() that calls exit() is
not usable in a library. An xalloc_die() that calls setjmp or throws a C++
exception would leak memory and would leave things in an inconsistent state.
This fixes it, by allowing the user to use alternative functions
(gl_list_nx_create instead of gl_list_create, etc.) that provide an error
indicator return value.
Thank you very much! :)
I updated the libgnupdf code to use the new 'nx' functions, caring
about the returned value.
Just a little-tiny typo fix:
diff --git a/lib/gl_list.h b/lib/gl_list.h
index ccbf8a3..9a23975 100644
--- a/lib/gl_list.h
+++ b/lib/gl_list.h
@@ -304,7 +304,7 @@ extern gl_list_node_t gl_list_nx_add_after (gl_list_t list,
gl_list_node_t node,
#endif
;
-/* Add an element add a given position in the list.
+/* Add an element at a given position in the list.
POSITION must be >= 0 and <= gl_list_size (list). */
#if 0 /* declared in gl_xlist.h */
extern gl_list_node_t gl_list_add_at (gl_list_t list, size_t position,