From: Jeremy Allison Date: Tue, 10 Nov 2020 21:43:24 +0000 (-0800) Subject: lib: create a wrapper for file_lines_parse(). X-Git-Tag: samba-4.14.0rc1~623 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=61f6672d8bbdbb6889be94591a7dbaeb55ab3d30;p=thirdparty%2Fsamba.git lib: create a wrapper for file_lines_parse(). Make the internal function file_lines_parse_internal(). Currently file_lines_parse() just wraps file_lines_parse_internal(), but this allows me to change file_lines_parse() to take a const char * to make it safe for callers (no talloc tricks). Signed-off-by: Jeremy Allison Reviewed-by: Guenther Deschner --- diff --git a/lib/util/util_file.c b/lib/util/util_file.c index 0c890f9b5ea..c95d02dd76f 100644 --- a/lib/util/util_file.c +++ b/lib/util/util_file.c @@ -253,7 +253,7 @@ _PUBLIC_ char *file_load(const char *fname, size_t *size, size_t maxsize, TALLOC parse a buffer into lines 'p' will be freed on error, and otherwise will be made a child of the returned array **/ -char **file_lines_parse(char *p, size_t size, int *numlines, TALLOC_CTX *mem_ctx) +static char **file_lines_parse_internal(char *p, size_t size, int *numlines, TALLOC_CTX *mem_ctx) { unsigned int i; char *s, **ret; @@ -305,7 +305,7 @@ _PUBLIC_ char **file_lines_load(const char *fname, int *numlines, size_t maxsize p = file_load(fname, &size, maxsize, mem_ctx); if (!p) return NULL; - return file_lines_parse(p, size, numlines, mem_ctx); + return file_lines_parse_internal(p, size, numlines, mem_ctx); } /** @@ -321,7 +321,15 @@ _PUBLIC_ char **fd_lines_load(int fd, int *numlines, size_t maxsize, TALLOC_CTX p = fd_load(fd, &size, maxsize, mem_ctx); if (!p) return NULL; - return file_lines_parse(p, size, numlines, mem_ctx); + return file_lines_parse_internal(p, size, numlines, mem_ctx); +} + +_PUBLIC_ char **file_lines_parse(char *p, + size_t size, + int *numlines, + TALLOC_CTX *mem_ctx) +{ + return file_lines_parse_internal(p, size, numlines, mem_ctx); } _PUBLIC_ bool file_save_mode(const char *fname, const void *packet,