Mercurial > molko
changeset 234:c89e2f7dbc01
core: remove readall in util
author | David Demelier <markand@malikania.fr> |
---|---|
date | Thu, 26 Nov 2020 13:33:31 +0100 |
parents | 081c71d1f723 |
children | fb304a94a05c |
files | libcore/core/util.c libcore/core/util.h |
diffstat | 2 files changed, 0 insertions(+), 45 deletions(-) [+] |
line wrap: on
line diff
--- 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 <sys/stat.h> #include <assert.h> -#include <errno.h> -#include <fcntl.h> #include <stdlib.h> -#include <unistd.h> #include <SDL.h> -#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) {
--- 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