summaryrefslogtreecommitdiffstats
path: root/src/dstring.h
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2023-11-09 15:16:04 -0500
committerTavian Barnes <tavianator@tavianator.com>2023-11-09 15:35:40 -0500
commite25261a90222de75781726a93ab809c660208afd (patch)
treeeed200bdebfd981821754a6bb154e3db30a109f5 /src/dstring.h
parentc745df94a182b8a569cb833ecfbe8da33bf01f98 (diff)
downloadbfs-e25261a90222de75781726a93ab809c660208afd.tar.xz
config: Add (de)allocator attributes
Diffstat (limited to 'src/dstring.h')
-rw-r--r--src/dstring.h21
1 files changed, 13 insertions, 8 deletions
diff --git a/src/dstring.h b/src/dstring.h
index fd98df8..07b4ee9 100644
--- a/src/dstring.h
+++ b/src/dstring.h
@@ -28,11 +28,20 @@ typedef char dchar;
#endif
/**
+ * Free a dynamic string.
+ *
+ * @param dstr
+ * The string to free.
+ */
+void dstrfree(dchar *dstr);
+
+/**
* Allocate a dynamic string.
*
* @param capacity
* The initial capacity of the string.
*/
+attr_malloc(dstrfree, 1)
dchar *dstralloc(size_t capacity);
/**
@@ -41,6 +50,7 @@ dchar *dstralloc(size_t capacity);
* @param str
* The NUL-terminated string to copy.
*/
+attr_malloc(dstrfree, 1)
dchar *dstrdup(const char *str);
/**
@@ -51,6 +61,7 @@ dchar *dstrdup(const char *str);
* @param n
* The maximum number of characters to copy from str.
*/
+attr_malloc(dstrfree, 1)
dchar *dstrndup(const char *str, size_t n);
/**
@@ -59,6 +70,7 @@ dchar *dstrndup(const char *str, size_t n);
* @param dstr
* The dynamic string to copy.
*/
+attr_malloc(dstrfree, 1)
dchar *dstrddup(const dchar *dstr);
/**
@@ -69,6 +81,7 @@ dchar *dstrddup(const dchar *dstr);
* @param len
* The length of the string, which may include internal NUL bytes.
*/
+attr_malloc(dstrfree, 1)
dchar *dstrxdup(const char *str, size_t len);
/**
@@ -306,12 +319,4 @@ int dstrescat(dchar **dest, const char *str, enum wesc_flags flags);
*/
int dstrnescat(dchar **dest, const char *str, size_t n, enum wesc_flags flags);
-/**
- * Free a dynamic string.
- *
- * @param dstr
- * The string to free.
- */
-void dstrfree(dchar *dstr);
-
#endif // BFS_DSTRING_H