From 5e9f5591873fc5c5b5c8dbb0e29a080b8afe9966 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 5 Jan 2000 06:36:36 +0000 Subject: implemented talloc() as described on samba-technical. This fixes the lp_string() bug properly. we still need to add lp_talloc_free() calls in all the main event loops, I've only put it in smbd and nmbd thus far. (This used to be commit aa7f81552540f5dca2c146f5edd805611d5b390f) --- source3/param/loadparm.c | 66 ++++++++++++++++++++---------------------------- 1 file changed, 27 insertions(+), 39 deletions(-) (limited to 'source3/param/loadparm.c') diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c index 6d825541302..b76af546098 100644 --- a/source3/param/loadparm.c +++ b/source3/param/loadparm.c @@ -1092,55 +1092,43 @@ static void init_locals(void) #define NUMBER_OF_STATIC_STRING_BUFS 20 +static TALLOC_CTX *lp_talloc; + /******************************************************************* a -convenience routine to grab string parameters into a rotating buffer, +free up temporary memory - called from the main loop +********************************************************************/ +void lp_talloc_free(void) +{ + if (!lp_talloc) return; + talloc_destroy(lp_talloc); + lp_talloc = NULL; +} + +/******************************************************************* +convenience routine to grab string parameters into temporary memory and run standard_sub_basic on them. The buffers can be written to by callers without affecting the source string. ********************************************************************/ static char *lp_string(const char *s) { - static char *bufs[NUMBER_OF_STATIC_STRING_BUFS]; - static size_t buflen[NUMBER_OF_STATIC_STRING_BUFS]; - static int next = -1; - char *ret; - int i; - size_t len = s?strlen(s):0; - - if (next == -1) { - /* initialisation */ - for (i=0;i