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)
| r5608 | r5614 | |
|---|---|---|
| 36 | 36 | static int cw_dynstr_grow(struct cw_dynstr **ds_p, size_t len) |
| 37 | 37 | { |
| 38 | 38 | struct cw_dynstr *nds; |
| 39 | size_t nsize = sizeof(**ds_p) + len; | |
| 39 | 40 | |
| 40 | 41 | if ((*ds_p) && (*ds_p)->chunk) |
| 41 | len = (len | (*ds_p)->chunk) + 1; | |
| 42 | nsize = (nsize | (*ds_p)->chunk) + 1; | |
| 42 | 43 | |
| 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 | } | |
| 47 | 50 | *ds_p = nds; |
| 48 | 51 | return 0; |
| 49 | 52 | } |
callweaver/trunk/include/callweaver/dynstr.h (unified diff)
| r5604 | r5614 | |
|---|---|---|
| 27 | 27 | #include "callweaver/preprocessor.h" |
| 28 | 28 | |
| 29 | 29 | |
| 30 | #define CW_DYNSTR_DEFAULT_CHUNK 64 | |
| 31 | ||
| 32 | ||
| 30 | 33 | struct cw_dynstr { |
| 31 | 34 | size_t size, chunk, used; |
| 32 | 35 | unsigned char error:1; |
![Home changeset 5614 [home]](/images/logo.png?1180520111)
RSS Feeds