diff options
| author | Leah Rowe <leah@libreboot.org> | 2026-03-29 09:10:57 +0100 |
|---|---|---|
| committer | Leah Rowe <leah@libreboot.org> | 2026-03-29 09:18:36 +0100 |
| commit | c2a70b7de0e15dc80d5b56d438a6d4ed47647b44 (patch) | |
| tree | 5c5281bb789f0ea9ab1d8766f5cea6e7182d431b /util/libreboot-utils/lib/string.c | |
| parent | 45edcf33f7d4b2f405c0f59fccc71b6ac15f5c65 (diff) | |
libreboot-utils: simplify random tmpdir namegen
generalise it in rand.c because this logic will
be useful for other programs in the future.
Signed-off-by: Leah Rowe <leah@libreboot.org>
Diffstat (limited to 'util/libreboot-utils/lib/string.c')
| -rw-r--r-- | util/libreboot-utils/lib/string.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/util/libreboot-utils/lib/string.c b/util/libreboot-utils/lib/string.c index 6a372dcf..c3cf4519 100644 --- a/util/libreboot-utils/lib/string.c +++ b/util/libreboot-utils/lib/string.c @@ -19,6 +19,20 @@ #include "../include/common.h" +void +free_and_set_null(char **buf) +{ + if (buf == NULL) + err_exit(EFAULT, + "null ptr (to ptr for freeing) in free_and_set_null"); + + if (*buf == NULL) + return; + + free(*buf); + *buf = NULL; +} + /* safe(ish) malloc. use this and free_and_set_null() |
