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)

r5594r5620
29822982 struct cw_dynstr *ds = NULL;
29832983
29842984 icd_caller__dump_debug_fd(that, &ds, " == ");
2985 cw_dynstr_free(ds);
2985 cw_dynstr_free(&ds);
29862986 }
29872987
29882988 void icd_caller__dump_debug_fd(icd_caller * that, struct cw_dynstr **ds_p, const char *indent)

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

r5616r5620
10011001 i = RESULT_SUCCESS;
10021002 }
10031003
1004 cw_dynstr_free(cmd);
1004 cw_dynstr_free(&cmd);
10051005 }
10061006
10071007 if (i != RESULT_SUCCESS)

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

r5619r5620
536536 if (msgtype == MSG_FOLLOWS) {
537537 if (ds) {
538538 smart_page((nresp >= 0), ds, ds_lines);
539 cw_dynstr_free(ds);
540 ds = NULL;
539 cw_dynstr_free(&ds);
541540 ds_lines = 0;
542541 }
543542 }

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

r5614r5620
2929 #include "callweaver/utils.h"
3030
3131
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)
3733 {
3834 struct cw_dynstr *nds;
3935 size_t nsize = sizeof(**ds_p) + len;

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

r5609r5620
18211821
18221822 cw_object_destroy(it);
18231823 if (it->data)
1824 cw_dynstr_free(it->data);
1824 cw_dynstr_free(&it->data);
18251825 free(it);
18261826 }
18271827

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

r5614r5620
5858 }
5959
6060
61 static inline void cw_dynstr_free(struct cw_dynstr *ds)
61 static inline void cw_dynstr_reset(struct cw_dynstr **ds_p)
6262 {
63 free(ds);
63 (*ds_p)->used = 0;
64 (*ds_p)->error = 0;
6465 }
6566
6667
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
6788 extern CW_API_PUBLIC int cw_dynstr_vprintf(struct cw_dynstr **ds_p, const char *fmt, va_list ap)
6889 __attribute__ ((__nonnull__ (1,2)));
6990 extern CW_API_PUBLIC int cw_dynstr_printf(struct cw_dynstr **ds_p, const char *fmt, ...)

callweaver/trunk/res/res_jabber.c (unified diff)

r5594r5620
17251725 struct cw_dynstr *ds = NULL;
17261726
17271727 cw_cli_command(&ds, (char *)cli_command);
1728 cw_dynstr_free(ds);
1728 cw_dynstr_free(&ds);
17291729 free(cli_command);
17301730
17311731 return NULL;

callweaver/trunk/res/res_monitor.c (unified diff)

r5613r5620
300300 cw_log(CW_LOG_ERROR, "Out of memory!\n");
301301
302302 if (cmd)
303 cw_dynstr_free(cmd);
303 cw_dynstr_free(&cmd);
304304 }
305305
306306 free(chan->monitor->format);