Changeset 5624
Fixes to dynamic strings
Committed by:
mjagdis
Date:
Feb 10 2010 * 19:07 (6 months ago)
Affected files:
callweaver/trunk/include/callweaver/dynstr.h (unified diff)
| r5620 | r5624 | |
|---|---|---|
| 59 | 59 | |
| 60 | 60 | |
| 61 | 61 | static inline void cw_dynstr_reset(struct cw_dynstr **ds_p) |
| 62 | __attribute__ ((nonnull (1))); | |
| 63 | ||
| 64 | static inline void cw_dynstr_reset(struct cw_dynstr **ds_p) | |
| 62 | 65 | { |
| 63 | (*ds_p)->used = 0; | |
| 64 | (*ds_p)->error = 0; | |
| 66 | if (*ds_p) | |
| 67 | (*ds_p)->used = (*ds_p)->error = 0; | |
| 65 | 68 | } |
| 66 | 69 | |
| 67 | 70 | |
| --- | --- | |
| 70 | 73 | |
| 71 | 74 | |
| 72 | 75 | static inline int cw_dynstr_need(struct cw_dynstr **ds_p, size_t len) |
| 76 | __attribute__ ((nonnull (1))); | |
| 77 | ||
| 78 | static inline int cw_dynstr_need(struct cw_dynstr **ds_p, size_t len) | |
| 73 | 79 | { |
| 74 | len += (*ds_p)->used; | |
| 75 | if (len > (*ds_p)->size) | |
| 80 | if (*ds_p) | |
| 81 | len += (*ds_p)->used; | |
| 82 | if (!(*ds_p) || len > (*ds_p)->size) | |
| 76 | 83 | cw_dynstr_grow(ds_p, len); |
| 77 | return (*ds_p)->error; | |
| 84 | return !(*ds_p) || (*ds_p)->error; | |
| 78 | 85 | } |
| 79 | 86 | |
| 80 | 87 | |
| 81 | static inline void cw_dynstr_free(struct cw_dynstr **ds) | |
| 88 | static inline void cw_dynstr_free(struct cw_dynstr **ds_p) | |
| 89 | __attribute__ ((nonnull (1))); | |
| 90 | ||
| 91 | static inline void cw_dynstr_free(struct cw_dynstr **ds_p) | |
| 82 | 92 | { |
| 83 | free(*ds); | |
| 84 | *ds = NULL; | |
| 93 | if (*ds_p) { | |
| 94 | free(*ds_p); | |
| 95 | *ds_p = NULL; | |
| 96 | } | |
| 85 | 97 | } |
| 86 | 98 | |
| 87 | 99 |
![Home changeset 5624 [home]](/images/logo.png?1180520111)
RSS Feeds