From: Marko Kreen Date: Mon, 11 Jan 2010 06:11:02 +0000 (+0200) Subject: X-Git-Tag: pgbouncer_1_4_rc3~72 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3090a9dba352d771a00d2625aef7a5e64fff7469;p=pgbouncer --- diff --git a/include/system.h b/include/system.h index ced43b8..cdb0bd9 100644 --- a/include/system.h +++ b/include/system.h @@ -28,7 +28,6 @@ #include -#include #include #include #include diff --git a/include/util.h b/include/util.h index d784cf5..5322800 100644 --- a/include/util.h +++ b/include/util.h @@ -16,11 +16,6 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* - * load file into malloced buffer - */ -char *load_file(const char *fn) _MUSTCHECK; - /* * logging about specific socket */ diff --git a/src/loader.c b/src/loader.c index ebabb00..15e5ade 100644 --- a/src/loader.c +++ b/src/loader.c @@ -26,6 +26,8 @@ #include #endif +#include + /* * ConnString parsing */ @@ -460,7 +462,7 @@ bool load_auth_file(const char *fn) { char *user, *password, *buf, *p; - buf = load_file(fn); + buf = load_file(fn, NULL); if (buf == NULL) { /* reset file info */ auth_loaded(NULL); @@ -686,7 +688,7 @@ bool iniparser(const char *fn, ConfSection *sect_list, bool reload) ConfSection *cur_section = NULL; char keybuf[MAX_DBNAME*2]; - buf = load_file(fn); + buf = load_file(fn, NULL); if (buf == NULL) { if (!reload) exit(1); diff --git a/src/util.c b/src/util.c index 9e8f5a0..f330c9f 100644 --- a/src/util.c +++ b/src/util.c @@ -50,50 +50,6 @@ int log_socket_prefix(enum LogLevel lev, void *ctx, char *dst, unsigned int dstl sock, db, user, host, port); } - -/* - * Load a file into malloc()-ed C string. - */ - -char *load_file(const char *fn) -{ - struct stat st; - char *buf = NULL; - int res, fd; - - res = stat(fn, &st); - if (res < 0) { - log_error("%s: %s", fn, strerror(errno)); - goto load_error; - } - - buf = malloc(st.st_size + 1); - if (!buf) { - log_error("%s: no mem", fn); - goto load_error; - } - - if ((fd = open(fn, O_RDONLY)) < 0) { - log_error("%s: %s", fn, strerror(errno)); - goto load_error; - } - - if ((res = safe_read(fd, buf, st.st_size)) < 0) { - log_error("%s: %s", fn, strerror(errno)); - goto load_error; - } - - close(fd); - buf[st.st_size] = 0; - - return buf; - -load_error: - if (buf != NULL) - free(buf); - return NULL; -} - /* * PostgreSQL MD5 hashing. */