summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ldap_convert.c2
-rw-r--r--str.c9
-rw-r--r--str.h1
3 files changed, 11 insertions, 1 deletions
diff --git a/ldap_convert.c b/ldap_convert.c
index 06e8176..568d68e 100644
--- a/ldap_convert.c
+++ b/ldap_convert.c
@@ -120,7 +120,7 @@ dn_to_text(const char *dn, const char *root_dn, ld_string_t *target)
count -= count_root;
}
- str_init_char(target, "");
+ str_clear(target);
for (unsigned int i = 0; exploded_dn[i] != NULL && i < count; i++) {
str_cat_char(target, exploded_dn[i]);
str_cat_char(target, ".");
diff --git a/str.c b/str.c
index c340e73..ee406e3 100644
--- a/str.c
+++ b/str.c
@@ -257,6 +257,15 @@ cleanup:
return result;
}
+void
+str_clear(ld_string_t *dest)
+{
+ REQUIRE(dest != NULL);
+
+ if (dest->allocated)
+ dest->data[0] = '\0';
+}
+
/*
* Initialize string from char *.
*/
diff --git a/str.h b/str.h
index 7026cc0..1d2c741 100644
--- a/str.h
+++ b/str.h
@@ -48,6 +48,7 @@ size_t str_len(const ld_string_t *str);
const char * str_buf(const ld_string_t *src);
isc_result_t str_copy(ld_string_t *dest, const ld_string_t *src);
isc_result_t str_clone(ld_string_t **dest, const ld_string_t *src _STR_MEM_FLARG);
+void str_clear(ld_string_t *dest);
isc_result_t str_init_char(ld_string_t *dest, const char *src);
isc_result_t str_cat_char(ld_string_t *dest, const char *src);
isc_result_t str_cat(ld_string_t *dest, const ld_string_t *src);