Changeset 5614

Add a default chunk size for dynstrs

Committed by:  mjagdis
Date:  Feb 05 2010 * 00:42 (6 months ago)

Affected files:

callweaver/trunk/corelib/dynstr.c (unified diff)

r5608r5614
3636 static int cw_dynstr_grow(struct cw_dynstr **ds_p, size_t len)
3737 {
3838 struct cw_dynstr *nds;
39 size_t nsize = sizeof(**ds_p) + len;
3940
4041 if ((*ds_p) && (*ds_p)->chunk)
41 len = (len | (*ds_p)->chunk) + 1;
42 nsize = (nsize | (*ds_p)->chunk) + 1;
4243
43 if ((nds = realloc(*ds_p, sizeof(**ds_p) + len))) {
44 nds->size = len;
45 if (!(*ds_p))
46 nds->chunk = nds->used = nds->error = 0;
44 if ((nds = realloc(*ds_p, nsize))) {
45 nds->size = nsize - sizeof(**ds_p);
46 if (!(*ds_p)) {
47 nds->chunk = CW_DYNSTR_DEFAULT_CHUNK;
48 nds->used = nds->error = 0;
49 }
4750 *ds_p = nds;
4851 return 0;
4952 }

callweaver/trunk/include/callweaver/dynstr.h (unified diff)

r5604r5614
2727 #include "callweaver/preprocessor.h"
2828
2929
30 #define CW_DYNSTR_DEFAULT_CHUNK 64
31
32
3033 struct cw_dynstr {
3134 size_t size, chunk, used;
3235 unsigned char error:1;