Changeset 5620
Make dynamic strings more opaque
Committed by:
mjagdis
Date:
Feb 09 2010 * 00:24 (6 months ago)
Affected files:
callweaver/trunk/apps/icd/icd_caller.c (unified diff)
| r5594 | r5620 | |
| 2982 | 2982 | struct cw_dynstr *ds = NULL; |
| 2983 | 2983 | |
| 2984 | 2984 | icd_caller__dump_debug_fd(that, &ds, " == "); |
| 2985 | | cw_dynstr_free(ds); |
| 2985 | cw_dynstr_free(&ds); |
| 2986 | 2986 | } |
| 2987 | 2987 | |
| 2988 | 2988 | void icd_caller__dump_debug_fd(icd_caller * that, struct cw_dynstr **ds_p, const char *indent) |
callweaver/trunk/corelib/callweaver.c (unified diff)
| r5616 | r5620 | |
| 1001 | 1001 | i = RESULT_SUCCESS; |
| 1002 | 1002 | } |
| 1003 | 1003 | |
| 1004 | | cw_dynstr_free(cmd); |
| 1004 | cw_dynstr_free(&cmd); |
| 1005 | 1005 | } |
| 1006 | 1006 | |
| 1007 | 1007 | if (i != RESULT_SUCCESS) |
callweaver/trunk/corelib/console.c (unified diff)
| r5619 | r5620 | |
| 536 | 536 | if (msgtype == MSG_FOLLOWS) { |
| 537 | 537 | if (ds) { |
| 538 | 538 | smart_page((nresp >= 0), ds, ds_lines); |
| 539 | | cw_dynstr_free(ds); |
| 540 | | ds = NULL; |
| 539 | cw_dynstr_free(&ds); |
| 541 | 540 | ds_lines = 0; |
| 542 | 541 | } |
| 543 | 542 | } |
callweaver/trunk/corelib/dynstr.c (unified diff)
| r5614 | r5620 | |
| 29 | 29 | #include "callweaver/utils.h" |
| 30 | 30 | |
| 31 | 31 | |
| 32 | | static int cw_dynstr_grow(struct cw_dynstr **ds_p, size_t len) |
| 33 | | __attribute__ ((nonnull (1))); |
| 34 | | |
| 35 | | |
| 36 | | static int cw_dynstr_grow(struct cw_dynstr **ds_p, size_t len) |
| 32 | int cw_dynstr_grow(struct cw_dynstr **ds_p, size_t len) |
| 37 | 33 | { |
| 38 | 34 | struct cw_dynstr *nds; |
| 39 | 35 | size_t nsize = sizeof(**ds_p) + len; |
callweaver/trunk/corelib/manager.c (unified diff)
| r5609 | r5620 | |
| 1821 | 1821 | |
| 1822 | 1822 | cw_object_destroy(it); |
| 1823 | 1823 | if (it->data) |
| 1824 | | cw_dynstr_free(it->data); |
| 1824 | cw_dynstr_free(&it->data); |
| 1825 | 1825 | free(it); |
| 1826 | 1826 | } |
| 1827 | 1827 | |
callweaver/trunk/include/callweaver/dynstr.h (unified diff)
| r5614 | r5620 | |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | |
| 61 | | static inline void cw_dynstr_free(struct cw_dynstr *ds) |
| 61 | static inline void cw_dynstr_reset(struct cw_dynstr **ds_p) |
| 62 | 62 | { |
| 63 | | free(ds); |
| 63 | (*ds_p)->used = 0; |
| 64 | (*ds_p)->error = 0; |
| 64 | 65 | } |
| 65 | 66 | |
| 66 | 67 | |
| 68 | extern CW_API_PUBLIC int cw_dynstr_grow(struct cw_dynstr **ds_p, size_t len) |
| 69 | __attribute__ ((nonnull (1))); |
| 70 | |
| 71 | |
| 72 | static inline int cw_dynstr_need(struct cw_dynstr **ds_p, size_t len) |
| 73 | { |
| 74 | len += (*ds_p)->used; |
| 75 | if (len > (*ds_p)->size) |
| 76 | cw_dynstr_grow(ds_p, len); |
| 77 | return (*ds_p)->error; |
| 78 | } |
| 79 | |
| 80 | |
| 81 | static inline void cw_dynstr_free(struct cw_dynstr **ds) |
| 82 | { |
| 83 | free(*ds); |
| 84 | *ds = NULL; |
| 85 | } |
| 86 | |
| 87 | |
| 67 | 88 | extern CW_API_PUBLIC int cw_dynstr_vprintf(struct cw_dynstr **ds_p, const char *fmt, va_list ap) |
| 68 | 89 | __attribute__ ((__nonnull__ (1,2))); |
| 69 | 90 | extern CW_API_PUBLIC int cw_dynstr_printf(struct cw_dynstr **ds_p, const char *fmt, ...) |
callweaver/trunk/res/res_jabber.c (unified diff)
| r5594 | r5620 | |
| 1725 | 1725 | struct cw_dynstr *ds = NULL; |
| 1726 | 1726 | |
| 1727 | 1727 | cw_cli_command(&ds, (char *)cli_command); |
| 1728 | | cw_dynstr_free(ds); |
| 1728 | cw_dynstr_free(&ds); |
| 1729 | 1729 | free(cli_command); |
| 1730 | 1730 | |
| 1731 | 1731 | return NULL; |
callweaver/trunk/res/res_monitor.c (unified diff)
| r5613 | r5620 | |
| 300 | 300 | cw_log(CW_LOG_ERROR, "Out of memory!\n"); |
| 301 | 301 | |
| 302 | 302 | if (cmd) |
| 303 | | cw_dynstr_free(cmd); |
| 303 | cw_dynstr_free(&cmd); |
| 304 | 304 | } |
| 305 | 305 | |
| 306 | 306 | free(chan->monitor->format); |