Mercurial > ~mikael > mcabber > hg
comparison mcabber/libjabber/pool.c @ 414:ec86d759ed54
Trailing whitespace cleanup
No real change.
author | Mikael Berthe <mikael@lilotux.net> |
---|---|
date | Tue, 30 Aug 2005 22:26:19 +0200 |
parents | bf3d6e241714 |
children | c3ae9251c197 |
comparison
equal
deleted
inserted
replaced
413:f7e4b0424081 | 414:ec86d759ed54 |
---|---|
13 * along with this program; if not, write to the Free Software | 13 * along with this program; if not, write to the Free Software |
14 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 14 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
15 * | 15 * |
16 * Jabber | 16 * Jabber |
17 * Copyright (C) 1998-1999 The Jabber Team http://jabber.org/ | 17 * Copyright (C) 1998-1999 The Jabber Team http://jabber.org/ |
18 * | 18 * |
19 * 2/27/00:3am, random plans by jer | 19 * 2/27/00:3am, random plans by jer |
20 * | 20 * |
21 * ok based on gprof, we really need some innovation here... my thoughs are this: | 21 * ok based on gprof, we really need some innovation here... my thoughs are this: |
22 * | 22 * |
23 * most things are strings, so have a string-based true-blue garbage collector | 23 * most things are strings, so have a string-based true-blue garbage collector |
24 * one big global hash containing all the strings created by any pstrdup, returning const char * | 24 * one big global hash containing all the strings created by any pstrdup, returning const char * |
25 * a refcount on each string block | 25 * a refcount on each string block |
26 * when a pool is freed, it moves down the refcount | 26 * when a pool is freed, it moves down the refcount |
27 * garbage collector collects pools on the free stack, and runs through the hash for unused strings | 27 * garbage collector collects pools on the free stack, and runs through the hash for unused strings |
28 * j_strcmp can check for == (if they are both from a pstrdup) | 28 * j_strcmp can check for == (if they are both from a pstrdup) |
29 * | 29 * |
30 * let's see... this would change: | 30 * let's see... this would change: |
31 * pstrdup: do a hash lookup, success=return, fail=pmalloc & hash put | 31 * pstrdup: do a hash lookup, success=return, fail=pmalloc & hash put |
32 * pool_free: | 32 * pool_free: |
33 * | 33 * |
34 * | 34 * |
35 * | 35 * |
36 * | |
37 * | |
38 */ | 36 */ |
39 | 37 |
40 #include "libxode.h" | 38 #include "libxode.h" |
41 | 39 |
42 #ifdef POOL_DEBUG | 40 #ifdef POOL_DEBUG |
188 { | 186 { |
189 void* result = pmalloc(p, size); | 187 void* result = pmalloc(p, size); |
190 if (result != NULL) | 188 if (result != NULL) |
191 memset(result, c, size); | 189 memset(result, c, size); |
192 return result; | 190 return result; |
193 } | 191 } |
194 | 192 |
195 /* easy safety utility (for creating blank mem for structs, etc) */ | 193 /* easy safety utility (for creating blank mem for structs, etc) */ |
196 void *pmalloco(pool p, int size) | 194 void *pmalloco(pool p, int size) |
197 { | 195 { |
198 void *block = pmalloc(p, size); | 196 void *block = pmalloc(p, size); |
199 memset(block, 0, size); | 197 memset(block, 0, size); |
200 return block; | 198 return block; |
201 } | 199 } |
202 | 200 |
203 /* XXX efficient: move this to const char * and then loop throug the existing heaps to see if src is within a block in this pool */ | 201 /* XXX efficient: move this to const char * and then loop throug the existing heaps to see if src is within a block in this pool */ |
204 char *pstrdup(pool p, const char *src) | 202 char *pstrdup(pool p, const char *src) |
205 { | 203 { |
206 char *ret; | 204 char *ret; |