[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[augeas-devel] augeas: master - * src/syntax.h (dup_string): duplicate a string



Gitweb:        http://git.fedorahosted.org/git/augeas.git?p=augeas.git;a=commitdiff;h=44afcf37bd5f2b7ed293e78149a6fc3931153eaa
Commit:        44afcf37bd5f2b7ed293e78149a6fc3931153eaa
Parent:        22cb8ecc61abf08304762fd19bef3cf77207321a
Author:        David Lutterkort <lutter redhat com>
AuthorDate:    Mon Mar 9 14:59:44 2009 -0700
Committer:     David Lutterkort <lutter redhat com>
CommitterDate: Mon Mar 9 15:38:13 2009 -0700

* src/syntax.h (dup_string): duplicate a string

---
 src/syntax.c |   12 ++++++++++++
 src/syntax.h |    3 +++
 2 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/src/syntax.c b/src/syntax.c
index 176de2b..04a1a87 100644
--- a/src/syntax.c
+++ b/src/syntax.c
@@ -359,6 +359,18 @@ struct string *make_string(char *str) {
     return string;
 }
 
+struct string *dup_string(const char *str) {
+    struct string *string;
+    make_ref(string);
+    if (str == NULL)
+        string->str = strdup("");
+    else
+        string->str = strdup(str);
+    if (string->str == NULL)
+        unref(string, string);
+    return string;
+}
+
 struct term *make_app_term(struct term *lambda, struct term *arg,
                            struct info *info) {
   struct term *app = make_term(A_APP, info);
diff --git a/src/syntax.h b/src/syntax.h
index b458bc6..3abe540 100644
--- a/src/syntax.h
+++ b/src/syntax.h
@@ -320,6 +320,9 @@ struct term *make_app_term(struct term *func, struct term *arg,
                            struct info *info);
 struct term *make_app_ident(char *id, struct term *func, struct info *info);
 
+/* Duplicate a string; if STR is NULL, use the empty string "" */
+struct string *dup_string(const char *str);
+
 /* Make an EXN value
  * Receive ownership of INFO
  *



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]