# HG changeset patch # User David Demelier # Date 1606394011 -3600 # Node ID c89e2f7dbc01eb5ccbc968cdee734fea3895bc59 # Parent 081c71d1f723e838607205af0320e8e5bbad3b29 core: remove readall in util diff -r 081c71d1f723 -r c89e2f7dbc01 libcore/core/util.c --- a/libcore/core/util.c Thu Nov 26 13:33:16 2020 +0100 +++ b/libcore/core/util.c Thu Nov 26 13:33:31 2020 +0100 @@ -16,17 +16,11 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include #include -#include -#include #include -#include #include -#include "alloc.h" -#include "error.h" #include "util.h" void @@ -35,33 +29,6 @@ SDL_Delay(ms); } -char * -readall(const char *path) -{ - int fd; - struct stat st; - char *str = NULL; - ssize_t nr; - - if ((fd = open(path, O_RDONLY)) < 0 || fstat(fd, &st) < 0) - goto io_error; - if (!(str = alloc_new0(st.st_size + 1))) - goto alloc_error; - if ((nr = read(fd, str, st.st_size)) != st.st_size) - goto io_error; - - return str; - -io_error: - errorf("%s", strerror(errno)); - -alloc_error: - close(fd); - free(str); - - return NULL; -} - unsigned int nrand(unsigned int lower, unsigned int upper) { diff -r 081c71d1f723 -r c89e2f7dbc01 libcore/core/util.h --- a/libcore/core/util.h Thu Nov 26 13:33:16 2020 +0100 +++ b/libcore/core/util.h Thu Nov 26 13:33:31 2020 +0100 @@ -50,18 +50,6 @@ delay(unsigned int ms); /** - * Read a whole file dynamically. - * - * \pre path != NULL - * \param path the path to the file - * \return A pointer to a dynamically allocated string containing the file - * contents or NULL on failures. - * \note Don't forget to free the result. - */ -char * -readall(const char *path); - -/** * Generate a random number between lower and upper (included). * * \pre upper must be <= RAND_MAX