From 37c0312def0b0c1b3c4248bd8d797db15d88d772 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 16 Apr 2000 09:40:02 +0000 Subject: added fdprintf() this is like fprintf() but operates on a file descriptor combined with file_load_lines() this makes it really easy to get rid of the use of fopen() in Samba. (This used to be commit bd5cd502bf52164b95d7bfc026189e04988171db) --- source3/lib/util_file.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'source3/lib/util_file.c') diff --git a/source3/lib/util_file.c b/source3/lib/util_file.c index 39c97d5c3f..d533e6428f 100644 --- a/source3/lib/util_file.c +++ b/source3/lib/util_file.c @@ -362,12 +362,13 @@ char **file_lines_load(char *fname, int *numlines) if (s[0] == '\n') i++; } - ret = (char **)malloc(sizeof(ret[0])*(i+1)); + ret = (char **)malloc(sizeof(ret[0])*(i+2)); if (!ret) { free(p); return NULL; } - *numlines = i; + memset(ret, 0, sizeof(ret[0])*(i+2)); + if (numlines) *numlines = i; ret[0] = p; for (s = p, i=0; s < p+size; s++) { @@ -391,3 +392,4 @@ void file_lines_free(char **lines) free(lines[0]); free(lines); } + -- cgit