add cx_strdup_m() and cx_strdup_ma()

Sat, 22 Apr 2023 19:01:06 +0200

author
Mike Becker <universe@uap-core.de>
date
Sat, 22 Apr 2023 19:01:06 +0200
changeset 700
72dccb560084
parent 699
35b2b99ee523
child 701
72a440c437e9

add cx_strdup_m() and cx_strdup_ma()

src/cx/string.h file | annotate | diff | comparison | revisions
     1.1 --- a/src/cx/string.h	Sat Apr 22 14:21:02 2023 +0200
     1.2 +++ b/src/cx/string.h	Sat Apr 22 19:01:06 2023 +0200
     1.3 @@ -774,6 +774,35 @@
     1.4   */
     1.5  #define cx_strdup(string) cx_strdup_a(cxDefaultAllocator, string)
     1.6  
     1.7 +
     1.8 +/**
     1.9 + * Creates a duplicate of the specified string.
    1.10 + *
    1.11 + * The new string will contain a copy allocated by \p allocator.
    1.12 + *
    1.13 + * \note The returned string is guaranteed to be zero-terminated.
    1.14 + *
    1.15 + * @param allocator the allocator to use
    1.16 + * @param string the string to duplicate
    1.17 + * @return a duplicate of the string
    1.18 + * @see cx_strdup_m()
    1.19 + */
    1.20 +#define cx_strdup_ma(allocator, string) cx_strdup_a(allocator, cx_strcast(string))
    1.21 +
    1.22 +/**
    1.23 + * Creates a duplicate of the specified string.
    1.24 + *
    1.25 + * The new string will contain a copy allocated by standard
    1.26 + * \c malloc(). So developers \em must pass the return value to cx_strfree().
    1.27 + *
    1.28 + * \note The returned string is guaranteed to be zero-terminated.
    1.29 + *
    1.30 + * @param string the string to duplicate
    1.31 + * @return a duplicate of the string
    1.32 + * @see cx_strdup_ma()
    1.33 + */
    1.34 +#define cx_strdup_m(string) cx_strdup_a(cxDefaultAllocator, cx_strcast(string))
    1.35 +
    1.36  /**
    1.37   * Omits leading and trailing spaces.
    1.38   *

mercurial