From c3dd4f53c37162366ca405f24cb122d0521280e1 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sun, 13 Oct 2024 11:35:12 +0200 Subject: [PATCH] string-desc: Fix categorization string_desc_new_addr. * lib/string-desc.h (string_desc_new_addr): Move to section "Side-effect-free operations". * lib/string-desc.c (string_desc_new_addr): Move accordingly. --- ChangeLog | 7 +++++++ lib/string-desc.c | 28 ++++++++++++++-------------- lib/string-desc.h | 6 +++--- 3 files changed, 24 insertions(+), 17 deletions(-) diff --git a/ChangeLog b/ChangeLog index ce225aa68e..d8aeaa5f51 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2024-10-13 Bruno Haible + + string-desc: Fix categorization string_desc_new_addr. + * lib/string-desc.h (string_desc_new_addr): Move to section + "Side-effect-free operations". + * lib/string-desc.c (string_desc_new_addr): Move accordingly. + 2024-10-12 Bruno Haible doc: Recommend string descriptors for application area like parsers. diff --git a/lib/string-desc.c b/lib/string-desc.c index 17856d9554..58a87e1220 100644 --- a/lib/string-desc.c +++ b/lib/string-desc.c @@ -119,6 +119,20 @@ string_desc_new_empty (void) } +string_desc_t +string_desc_new_addr (idx_t n, char *addr) +{ + string_desc_t result; + + result._nbytes = n; + if (n == 0) + result._data = NULL; + else + result._data = addr; + + return result; +} + string_desc_t string_desc_from_c (const char *s) { @@ -191,20 +205,6 @@ string_desc_new (string_desc_t *resultp, idx_t n) return 0; } -string_desc_t -string_desc_new_addr (idx_t n, char *addr) -{ - string_desc_t result; - - result._nbytes = n; - if (n == 0) - result._data = NULL; - else - result._data = addr; - - return result; -} - int string_desc_new_filled (string_desc_t *resultp, idx_t n, char c) { diff --git a/lib/string-desc.h b/lib/string-desc.h index e5c969ca83..ff9c86d6a0 100644 --- a/lib/string-desc.h +++ b/lib/string-desc.h @@ -117,6 +117,9 @@ extern ptrdiff_t string_desc_contains (string_desc_t haystack, string_desc_t nee /* Return an empty string. */ extern string_desc_t string_desc_new_empty (void); +/* Construct and return a string of length N, at the given memory address. */ +extern string_desc_t string_desc_new_addr (idx_t n, char *addr); + /* Return a string that represents the C string S, of length strlen (S). */ extern string_desc_t string_desc_from_c (const char *s); @@ -146,9 +149,6 @@ extern int string_desc_fwrite (FILE *fp, string_desc_t s); _GL_ATTRIBUTE_NODISCARD extern int string_desc_new (string_desc_t *resultp, idx_t n); -/* Construct and return a string of length N, at the given memory address. */ -extern string_desc_t string_desc_new_addr (idx_t n, char *addr); - /* Construct a string of length N, filled with C. Return 0 if successful. Upon error, return -1 with errno set. */ -- 2.39.5