rpi4b-temp-humidity/util.c

30 lines
742 B
C
Raw Normal View History

2024-02-23 22:56:10 -08:00
/*
* util.c - Utility functions
* Copyright (C) 2024 Alexander Rosenberg
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version. See the LICENSE file for more information.
*/
#include "util.h"
#include <err.h>
struct GlobalFlags GLOBAL_FLAGS = {
.config_path = NULL,
.gpio_path = NULL,
};
void *malloc_checked(size_t n) {
return realloc_checked(NULL, n);
}
void *realloc_checked(void *old_ptr, size_t n) {
void *ptr = realloc(old_ptr, n);
if (n && !ptr) {
errx(1, "out of memory!");
}
return ptr;
}