Add OutOfMemory log helper

Add a special LOG_OOM() function to log all OutOfMemory errors (i.e.
allocations returning NULL).
This commit is contained in:
Romain Vimont
2021-11-24 22:06:11 +01:00
parent 92a458e846
commit 3653fb6b15
26 changed files with 77 additions and 56 deletions

View File

@@ -7,6 +7,8 @@
#include <sys/stat.h>
#include <unistd.h>
#include "util/log.h"
bool
sc_file_executable_exists(const char *file) {
char *path = getenv("PATH");
@@ -24,7 +26,10 @@ sc_file_executable_exists(const char *file) {
size_t dir_len = strlen(dir);
char *fullpath = malloc(dir_len + file_len + 2);
if (!fullpath)
{
LOG_OOM();
continue;
}
memcpy(fullpath, dir, dir_len);
fullpath[dir_len] = '/';
memcpy(fullpath + dir_len + 1, file, file_len + 1);