summaryrefslogtreecommitdiff
path: root/lib/darr.h
diff options
context:
space:
mode:
authorDonald Sharp <donaldsharp72@gmail.com>2025-03-14 10:33:16 -0400
committerGitHub <noreply@github.com>2025-03-14 10:33:16 -0400
commitdbecefb6c6eac3ad9d798e66ae2a8c572590c0bd (patch)
treebb9e0e202ba7921fde81e5e775e51187a925769a /lib/darr.h
parente5848deedf01f77194b3cff457dc462230c257da (diff)
parent2586c4c3edeab982d65071e5d90329ba47189af4 (diff)
Merge pull request #18383 from LabNConsulting/chopps/fix-oper-state-list-query-bug
Fix bug with oper-state queries including list node
Diffstat (limited to 'lib/darr.h')
-rw-r--r--lib/darr.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/darr.h b/lib/darr.h
index 084c2a103a..4638b904d1 100644
--- a/lib/darr.h
+++ b/lib/darr.h
@@ -62,6 +62,7 @@
* - darr_strdup
* - darr_strdup_cap
* - darr_strlen
+ * - darr_strlen_fixup
* - darr_strnul
* - darr_sprintf, darr_vsprintf
*/
@@ -753,6 +754,22 @@ void *__darr_resize(void *a, uint count, size_t esize, struct memtype *mt);
})
/**
+ * Fixup darr_len (and thus darr_strlen) for `S` based on its strlen(S)
+ * (i.e., scan for NUL byte). The dynamic array length will be set to strlen(S) + 1.
+ *
+ * Args:
+ * S: The dynamic array with a NUL terminated string, cannot be NULL.
+ *
+ * Return:
+ * The calculated strlen() value.
+ */
+#define darr_strlen_fixup(S) \
+ ({ \
+ _darr_len(S) = strlen(S) + 1; \
+ darr_strlen(S); \
+ })
+
+/**
* darr_vsprintf() - vsprintf into a new dynamic array.
*
* Args: