summaryrefslogtreecommitdiff
path: root/src/str.c
diff options
context:
space:
mode:
authorMichael Jennings <mej@kainx.org>2002-05-21 04:20:25 +0000
committerMichael Jennings <mej@kainx.org>2002-05-21 04:20:25 +0000
commite75bbc9ae8dd4450128ee4324a36fc668f7d9467 (patch)
treea9086017e12862e3cf33b4c9620f1aa582beca7e /src/str.c
parentc18aed0d9a7c07dde656ac0a23de690322d1d327 (diff)
downloadlibast-e75bbc9ae8dd4450128ee4324a36fc668f7d9467.tar.gz
Tue May 21 00:15:37 2002 Michael Jennings (mej)
Fixed a number of memory leaks in both the testing code and the object classes themselves. Also rearranged some header stuff and created a few new helper macros for object declarations. SVN revision: 6265
Diffstat (limited to 'src/str.c')
-rw-r--r--src/str.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/src/str.c b/src/str.c
index 3d66c5e..8e25829 100644
--- a/src/str.c
+++ b/src/str.c
@@ -32,10 +32,10 @@ static const char cvs_ident[] = "$Id$";
/* *INDENT-OFF* */
static spif_const_class_t s_class = {
SPIF_DECL_CLASSNAME(str),
- (spif_newfunc_t) spif_str_new,
- (spif_memberfunc_t) spif_str_init,
- (spif_memberfunc_t) spif_str_done,
- (spif_memberfunc_t) spif_str_del,
+ (spif_func_t) spif_str_new,
+ (spif_func_t) spif_str_init,
+ (spif_func_t) spif_str_done,
+ (spif_func_t) spif_str_del,
(spif_func_t) spif_str_show,
(spif_func_t) spif_str_cmp,
(spif_func_t) spif_str_dup,
@@ -411,6 +411,7 @@ spif_str_splice(spif_str_t self, size_t idx, size_t cnt, spif_str_t other)
}
self->len = newsize - 1;
memcpy(self->s, tmp, newsize);
+ FREE(tmp);
return TRUE;
}
@@ -436,6 +437,7 @@ spif_str_splice_from_ptr(spif_str_t self, size_t idx, size_t cnt, spif_charptr_t
}
self->len = newsize - 1;
memcpy(self->s, tmp, newsize);
+ FREE(tmp);
return TRUE;
}
@@ -496,13 +498,15 @@ spif_str_show(spif_str_t self, spif_charptr_t name, spif_str_t buff, size_t inde
{
char tmp[4096];
- memset(tmp, ' ', indent);
if (SPIF_STR_ISNULL(self)) {
- snprintf(tmp + indent, sizeof(tmp) - indent, "(spif_str_t) %s: " SPIF_NULLSTR_TYPE(str) "\n", NONULL(name));
- } else {
- snprintf(tmp + indent, sizeof(tmp) - indent, "(spif_str_t) %s: { \"%s\", len %lu, size %lu }\n",
- name, self->s, (unsigned long) self->len, (unsigned long) self->mem);
+ SPIF_OBJ_SHOW_NULL("str", name, buff, indent);
+ return buff;
}
+
+ memset(tmp, ' ', indent);
+ snprintf(tmp + indent, sizeof(tmp) - indent, "(spif_str_t) %s: { \"%s\", len %lu, size %lu }\n",
+ name, self->s, (unsigned long) self->len, (unsigned long) self->mem);
+
if (SPIF_STR_ISNULL(buff)) {
buff = spif_str_new_from_ptr(tmp);
} else {