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>
This commit is contained in:
Leah Rowe
2026-03-29 09:10:57 +01:00
parent 45edcf33f7
commit c2a70b7de0
6 changed files with 57 additions and 82 deletions
+14
View File
@@ -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()