mirror of
https://codeberg.org/libreboot/lbmk.git
synced 2026-07-13 06:49:52 +02:00
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:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user