]> git.ipfire.org Git - thirdparty/mlmmj.git/commitdiff
modern C: replace malloc+snprintf with asprintf
authorBaptiste Daroussin <bapt@FreeBSD.org>
Thu, 20 Oct 2022 11:25:47 +0000 (13:25 +0200)
committerBaptiste Daroussin <bapt@FreeBSD.org>
Thu, 20 Oct 2022 11:25:47 +0000 (13:25 +0200)
src/strgen.c

index 2ef3e6d3fff7a9ef86a4238f45b2add84aaab7e3..15d6b6b37ace8ba6be78b5d131a68649f4189bc1 100644 (file)
 
 char *random_str()
 {
-       size_t len = 17; /* sixteen hex digits plus terminating zero */
-       char *dest = xmalloc(len);
+       char *dest;
 
-       snprintf(dest, len, "%08x%08x", random_int(), random_int());
+       xasprintf(&dest, "%08x%08x", random_int(), random_int());
 
        return dest;
 }