summaryrefslogtreecommitdiff
path: root/app/dynstring
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2020-08-08 11:53:00 +0200
committerJörg Frings-Fürst <debian@jff-webhosting.net>2020-08-08 11:53:00 +0200
commitb623f5953691b2a0614e6f1f4def86bdbb9a4113 (patch)
tree18102bd36f7e22eb2ba2b9f880e4cb29346f4cb8 /app/dynstring
parent359b557176b9bb2ff1aed2082641eed39c358d0d (diff)
New upstream version 5.2.0Beta2.1upstream/5.2.0Beta2.1
Diffstat (limited to 'app/dynstring')
-rw-r--r--app/dynstring/dynstring.c17
-rw-r--r--app/dynstring/dynstring.h89
2 files changed, 62 insertions, 44 deletions
diff --git a/app/dynstring/dynstring.c b/app/dynstring/dynstring.c
index eb7b2c5..fd50a0b 100644
--- a/app/dynstring/dynstring.c
+++ b/app/dynstring/dynstring.c
@@ -115,6 +115,23 @@ void DynStringClear(DynString *s)
DynStringRealloc(s);
}
+
+/**
+* Clear the dynamic string contents without changing memory allocation.
+*
+* \param s IN the dynamic string
+*/
+
+void DynStringReset(DynString *s)
+{
+ /* Not a string? */
+ if (isnas(s))
+ {
+ return;
+ }
+ s->size = 0;
+}
+
/**
* Resize the string for a minimum number of bytes. In order to optimize memory usage the
* actually allocated block of memory can be larger than the requested size.
diff --git a/app/dynstring/dynstring.h b/app/dynstring/dynstring.h
index 2a18409..0a5b972 100644
--- a/app/dynstring/dynstring.h
+++ b/app/dynstring/dynstring.h
@@ -1,3 +1,4 @@
+
/** \file dynstring.h
* Definitions and prototypes for variable length strings
*/
@@ -18,47 +19,47 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-*/
-
-#ifndef HAVE_DYNSTRING_H
-#define HAVE_DYNSTRING_H
-
-#include <stddef.h>
-
-struct DynString
-{
- char *s;
- size_t size; // length of the string
- size_t b_size; // length of the buffer containing the string
-};
-typedef struct DynString DynString;
-
-#define NaS {NULL, 0, 0}
-#define isnas(S) (!(S)->s)
-
-// define highest bit depending on 32 or 64 bit compile
-
-#if defined(__LP64__) || defined(_WIN64) || (defined(__x86_64__) && !defined(__ILP32__) ) || defined(_M_X64) || defined(__ia64) || defined (_M_IA64) || defined(__aarch64__) || defined(__powerpc64__)
- #define STR_FREEABLE (1ULL << 63)
-#else
- #define STR_FREEABLE (1ULL << 31)
-#endif
-
-size_t DynStringSize(DynString * s);
-
-DynString * DynStringMalloc(DynString *s, size_t size);
-void DynStringClear(DynString *s);
-void DynStringRealloc(DynString * s);
-void DynStringResize(DynString * s, size_t size);
-void DynStringFree(DynString * s);
-DynString * DynStringDupStr(DynString *s2, DynString * s);
-void DynStringCpyStr(DynString * dest, DynString * src);
-char * DynStringToCStr(DynString * s);
-void DynStringNCatCStr(DynString * s, size_t len, const char * str);
-void DynStringCatCStr(DynString * s, const char * str);
-void DynStringCatStr(DynString * s, const DynString * s2);
-void DynStringCatCStrs(DynString * s, ...);
-void DynStringCatStrs(DynString * s1, ...);
-void DynStringPrintf(DynString * s, const char * fmt, ...);
-
-#endif // !HAVE_DYNSTRING_H
+*/
+
+#ifndef HAVE_DYNSTRING_H
+#define HAVE_DYNSTRING_H
+
+#include <stddef.h>
+
+struct DynString
+{
+ char *s;
+ size_t size; // length of the string
+ size_t b_size; // length of the buffer containing the string
+};
+typedef struct DynString DynString;
+
+#define NaS {NULL, 0, 0}
+#define isnas(S) (!(S)->s)
+
+// define highest bit depending on 32 or 64 bit compile
+
+#if defined(__LP64__) || defined(_WIN64) || (defined(__x86_64__) && !defined(__ILP32__) ) || defined(_M_X64) || defined(__ia64) || defined (_M_IA64) || defined(__aarch64__) || defined(__powerpc64__)
+ #define STR_FREEABLE (1ULL << 63)
+#else
+ #define STR_FREEABLE (1ULL << 31)
+#endif
+
+size_t DynStringSize(DynString * s);
+
+DynString * DynStringMalloc(DynString *s, size_t size);
+void DynStringClear(DynString *s);
+void DynStringRealloc(DynString * s);
+void DynStringResize(DynString * s, size_t size);
+void DynStringFree(DynString * s);
+DynString * DynStringDupStr(DynString *s2, DynString * s);
+void DynStringCpyStr(DynString * dest, DynString * src);
+char * DynStringToCStr(DynString * s);
+void DynStringNCatCStr(DynString * s, size_t len, const char * str);
+void DynStringCatCStr(DynString * s, const char * str);
+void DynStringCatStr(DynString * s, const DynString * s2);
+void DynStringCatCStrs(DynString * s, ...);
+void DynStringCatStrs(DynString * s1, ...);
+void DynStringPrintf(DynString * s, const char * fmt, ...);
+void DynStringReset(DynString * s);
+#endif // !HAVE_DYNSTRING_H