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)

r5620r5624
5959
6060
6161 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)
6265 {
63 (*ds_p)->used = 0;
64 (*ds_p)->error = 0;
66 if (*ds_p)
67 (*ds_p)->used = (*ds_p)->error = 0;
6568 }
6669
6770
------
7073
7174
7275 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)
7379 {
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)
7683 cw_dynstr_grow(ds_p, len);
77 return (*ds_p)->error;
84 return !(*ds_p) || (*ds_p)->error;
7885 }
7986
8087
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)
8292 {
83 free(*ds);
84 *ds = NULL;
93 if (*ds_p) {
94 free(*ds_p);
95 *ds_p = NULL;
96 }
8597 }
8698
8799