The branch, master has been updated
       via  d825adf s3-param: Remove never-reached condition for popts == NULL
       via  31d1fde s3-param: Remove never-reached condition for opt_list == 
NULL
       via  d65bded source3/loadparm.c: Move string_set/string_free inside.
       via  3bb65aa source3/smbd/conn.c: wean off string_set/string_free
       via  a14c02d source3/loadparm: make struct loadparm_service a talloc 
object.
       via  592e3f4 loadparm: Add ctx member to struct loadparm_global.
      from  9b7b736 media_harmony VFS module: Add and build by default.

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit d825adf86a91aa08588ef5fa95ce3f91abb9fd40
Author: Andrew Bartlett <abart...@samba.org>
Date:   Tue Aug 7 21:29:53 2012 +1000

    s3-param: Remove never-reached condition for popts == NULL
    
    All the callers provide a parametric options pointer to fill in.
    
    Andrew Bartlett
    
    Autobuild-User(master): Andrew Bartlett <abart...@samba.org>
    Autobuild-Date(master): Tue Aug  7 17:16:38 CEST 2012 on sn-devel-104

commit 31d1fde037d78e2c2becdedb9016a859e5e38437
Author: Andrew Bartlett <abart...@samba.org>
Date:   Tue Aug 7 21:20:47 2012 +1000

    s3-param: Remove never-reached condition for opt_list == NULL
    
    All the callers provide a parametric options pointer to fill in.
    
    Andrew Bartlett

commit d65bded0c2435a62bf0fe33828d6dc5b9a74f936
Author: Rusty Russell <ru...@rustcorp.com.au>
Date:   Mon Jul 23 14:51:39 2012 +0930

    source3/loadparm.c: Move string_set/string_free inside.
    
    The only user, so make them static inside loadparm.c
    
    Signed-off-by: Rusty Russell <ru...@rustcorp.com.au>
    Signed-off-by: Andrew Bartlett <abart...@samba.org>

commit 3bb65aa159cae310b2a5d4998c258d72ace2fa3f
Author: Rusty Russell <ru...@rustcorp.com.au>
Date:   Mon Jul 23 14:51:34 2012 +0930

    source3/smbd/conn.c: wean off string_set/string_free
    
    Use straight talloc strings.  This is the only user outside loadparm.c.
    
    Signed-off-by: Rusty Russell <ru...@rustcorp.com.au>
    Signed-off-by: Andrew Bartlett <abart...@samba.org>

commit a14c02d2a7b9d070a6338a360103a34e7673454c
Author: Rusty Russell <ru...@rustcorp.com.au>
Date:   Mon Jul 23 12:20:26 2012 +0930

    source3/loadparm: make struct loadparm_service a talloc object.
    
    This gives us a place to allocate members from.
    
    Signed-off-by: Rusty Russell <ru...@rustcorp.com.au>
    Signed-off-by: Andrew Bartlett <abart...@samba.org>

commit 592e3f4b236b3b5c056faca6ca6f060560a3204d
Author: Rusty Russell <ru...@rustcorp.com.au>
Date:   Mon Jul 23 12:19:46 2012 +0930

    loadparm: Add ctx member to struct loadparm_global.
    
    Rather than tallocing global parameters off NULL, keep it neat by having
    a Global.ctx member.
    
    Signed-off-by: Rusty Russell <ru...@rustcorp.com.au>
    Signed-off-by: Andrew Bartlett <abart...@samba.org>

-----------------------------------------------------------------------

Summary of changes:
 script/mkparamdefs.pl     |    4 ++-
 source3/Makefile.in       |    2 +-
 source3/include/proto.h   |    2 -
 source3/lib/string_init.c |   77 ---------------------------------------------
 source3/param/loadparm.c  |   66 +++++++++++++++++++++++++++++++++-----
 source3/smbd/conn.c       |   10 ++----
 source3/smbd/service.c    |    9 +++--
 source3/wscript_build     |    2 +-
 8 files changed, 70 insertions(+), 102 deletions(-)
 delete mode 100644 source3/lib/string_init.c


Changeset truncated at 500 lines:

diff --git a/script/mkparamdefs.pl b/script/mkparamdefs.pl
index b489cc9..6b59230 100644
--- a/script/mkparamdefs.pl
+++ b/script/mkparamdefs.pl
@@ -91,12 +91,14 @@ $file->("/* This file was automatically generated by 
mkparamdefs.pl. DO NOT EDIT
            $file->(" * This structure describes global (ie., server-wide) 
parameters.\n");
            $file->(" */\n");
            $file->("struct loadparm_global \n");
+           $file->("{\n");
+           $file->("\tTALLOC_CTX *ctx; /* Context for talloced members */\n");
        } elsif ($generate_scope eq "LOCAL") {
            $file->(" * This structure describes a single service.\n");
            $file->(" */\n");
            $file->("struct loadparm_service \n");
+           $file->("{\n");
        }
-$file->("{\n");
 }
 
 sub print_footer($$$)
diff --git a/source3/Makefile.in b/source3/Makefile.in
index ff0f1f4..e42c1b5 100644
--- a/source3/Makefile.in
+++ b/source3/Makefile.in
@@ -466,7 +466,7 @@ LIB_OBJ = $(LIBSAMBAUTIL_OBJ) $(UTIL_OBJ) $(CRYPTO_OBJ) 
$(LIBTSOCKET_OBJ) \
          ../libds/common/flag_mapping.o \
          lib/access.o lib/smbrun.o \
          ../lib/util/bitmap.o ../lib/util/dprintf.o $(UTIL_REG_OBJ) \
-         lib/wins_srv.o lib/string_init.o \
+         lib/wins_srv.o \
          lib/util_str.o ../lib/util/util_str_common.o \
          ../lib/util/util_str.o \
          ../lib/util/base64.o lib/util_sid.o \
diff --git a/source3/include/proto.h b/source3/include/proto.h
index 101d62d..ebb76ef 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -671,8 +671,6 @@ bool strhasupper(const char *s);
 bool strhaslower(const char *s);
 char *StrnCpy(char *dest,const char *src,size_t n);
 bool in_list(const char *s, const char *list, bool casesensitive);
-void string_free(char **s);
-bool string_set(char **dest,const char *src);
 void fstring_sub(char *s,const char *pattern,const char *insert);
 char *realloc_string_sub2(char *string,
                        const char *pattern,
diff --git a/source3/lib/string_init.c b/source3/lib/string_init.c
deleted file mode 100644
index 40a6ef0..0000000
--- a/source3/lib/string_init.c
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
-   Unix SMB/CIFS implementation.
-   Samba utility functions
-
-   Copyright (C) Andrew Tridgell 1992-2001
-   Copyright (C) Simo Sorce      2001-2002
-   Copyright (C) Martin Pool     2003
-   Copyright (C) James Peach    2006
-   Copyright (C) Jeremy Allison  1992-2007
-
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 3 of the License, or
-   (at your option) any later version.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program.  If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "includes.h"
-
-/* this is used to prevent lots of mallocs of size 1 */
-static const char null_string[] = "";
-
-/**
- Set a string value, allocing the space for the string
-**/
-
-static bool string_init(char **dest,const char *src)
-{
-       size_t l;
-
-       if (!src)
-               src = "";
-
-       l = strlen(src);
-
-       if (l == 0) {
-               *dest = discard_const_p(char, null_string);
-       } else {
-               (*dest) = SMB_STRDUP(src);
-               if ((*dest) == NULL) {
-                       DEBUG(0,("Out of memory in string_init\n"));
-                       return false;
-               }
-       }
-       return(true);
-}
-
-/**
- Free a string value.
-**/
-
-void string_free(char **s)
-{
-       if (!s || !(*s))
-               return;
-       if (*s == null_string)
-               *s = NULL;
-       SAFE_FREE(*s);
-}
-
-/**
- Set a string value, deallocating any existing space, and allocing the space
- for the string
-**/
-
-bool string_set(char **dest,const char *src)
-{
-       string_free(dest);
-       return(string_init(dest,src));
-}
diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c
index 1b766c3..d4ee8a2 100644
--- a/source3/param/loadparm.c
+++ b/source3/param/loadparm.c
@@ -326,6 +326,58 @@ static void free_param_opts(struct parmlist_entry **popts);
 
 #include "lib/param/param_table.c"
 
+/* this is used to prevent lots of mallocs of size 1 */
+static const char null_string[] = "";
+
+/**
+ Set a string value, allocing the space for the string
+**/
+
+static bool string_init(char **dest,const char *src)
+{
+       size_t l;
+
+       if (!src)
+               src = "";
+
+       l = strlen(src);
+
+       if (l == 0) {
+               *dest = discard_const_p(char, null_string);
+       } else {
+               (*dest) = SMB_STRDUP(src);
+               if ((*dest) == NULL) {
+                       DEBUG(0,("Out of memory in string_init\n"));
+                       return false;
+               }
+       }
+       return(true);
+}
+
+/**
+ Free a string value.
+**/
+
+static void string_free(char **s)
+{
+       if (!s || !(*s))
+               return;
+       if (*s == null_string)
+               *s = NULL;
+       SAFE_FREE(*s);
+}
+
+/**
+ Set a string value, deallocating any existing space, and allocing the space
+ for the string
+**/
+
+static bool string_set(char **dest,const char *src)
+{
+       string_free(dest);
+       return(string_init(dest,src));
+}
+
 /***************************************************************************
  Initialise the sDefault parameter structure for the printer values.
 ***************************************************************************/
@@ -593,6 +645,7 @@ static void free_global_parameters(void)
 {
        free_param_opts(&Globals.param_opt);
        free_parameters_by_snum(GLOBAL_SECTION_SNUM);
+       TALLOC_FREE(Globals.ctx);
 }
 
 static int map_parameter(const char *pszParmName);
@@ -690,6 +743,8 @@ static void init_globals(bool reinit_globals)
         * table once the defaults are set */
        ZERO_STRUCT(Globals);
 
+       Globals.ctx = talloc_new(NULL);
+
        for (i = 0; parm_table[i].label; i++) {
                if ((parm_table[i].type == P_STRING ||
                     parm_table[i].type == P_USTRING))
@@ -1440,10 +1495,6 @@ static void free_param_opts(struct parmlist_entry 
**popts)
 {
        struct parmlist_entry *opt, *next_opt;
 
-       if (popts == NULL) {
-               return;
-       }
-
        if (*popts != NULL) {
                DEBUG(5, ("Freeing parametrics:\n"));
        }
@@ -1508,6 +1559,7 @@ static void free_service_byindex(int idx)
        }
 
        free_service(ServicePtrs[idx]);
+       talloc_free_children(ServicePtrs[idx]);
 }
 
 /***************************************************************************
@@ -1548,7 +1600,7 @@ static int add_a_service(const struct loadparm_service 
*pservice, const char *na
                        return (-1);
                }
                ServicePtrs = tsp;
-               ServicePtrs[iNumServices] = SMB_MALLOC_P(struct 
loadparm_service);
+               ServicePtrs[iNumServices] = talloc(NULL, struct 
loadparm_service);
                if (!ServicePtrs[iNumServices]) {
                        DEBUG(0,("add_a_service: out of memory!\n"));
                        return (-1);
@@ -2198,10 +2250,6 @@ static void set_param_opt(struct parmlist_entry 
**opt_list,
        struct parmlist_entry *new_opt, *opt;
        bool not_added;
 
-       if (opt_list == NULL) {
-               return;
-       }
-
        opt = *opt_list;
        not_added = true;
 
diff --git a/source3/smbd/conn.c b/source3/smbd/conn.c
index 28e1850..bc5a03b 100644
--- a/source3/smbd/conn.c
+++ b/source3/smbd/conn.c
@@ -62,7 +62,9 @@ connection_struct *conn_new(struct smbd_server_connection 
*sconn)
        connection_struct *conn;
 
        if (!(conn=talloc_zero(NULL, connection_struct)) ||
-           !(conn->params = talloc(conn, struct share_params))) {
+           !(conn->params = talloc(conn, struct share_params)) ||
+           !(conn->connectpath = talloc_strdup(conn, "")) ||
+           !(conn->origpath = talloc_strdup(conn, ""))) {
                DEBUG(0,("TALLOC_ZERO() failed!\n"));
                TALLOC_FREE(conn);
                return NULL;
@@ -70,9 +72,6 @@ connection_struct *conn_new(struct smbd_server_connection 
*sconn)
        conn->sconn = sconn;
        conn->force_group_gid = (gid_t)-1;
 
-       string_set(&conn->connectpath,"");
-       string_set(&conn->origpath,"");
-
        DLIST_ADD(sconn->connections, conn);
        sconn->num_connections++;
 
@@ -171,9 +170,6 @@ static void conn_free_internal(connection_struct *conn)
        free_namearray(conn->veto_oplock_list);
        free_namearray(conn->aio_write_behind_list);
 
-       string_free(&conn->connectpath);
-       string_free(&conn->origpath);
-
        ZERO_STRUCTP(conn);
        talloc_destroy(conn);
 }
diff --git a/source3/smbd/service.c b/source3/smbd/service.c
index a1d009c..4fc1aa3 100644
--- a/source3/smbd/service.c
+++ b/source3/smbd/service.c
@@ -61,7 +61,7 @@ bool set_conn_connectpath(connection_struct *conn, const char 
*connectpath)
        }
 
        /* Allocate for strlen + '\0' + possible leading '/' */
-       destname = (char *)SMB_MALLOC(strlen(connectpath) + 2);
+       destname = (char *)talloc_size(conn, strlen(connectpath) + 2);
        if (!destname) {
                return false;
        }
@@ -162,8 +162,8 @@ bool set_conn_connectpath(connection_struct *conn, const 
char *connectpath)
        DEBUG(10,("set_conn_connectpath: service %s, connectpath = %s\n",
                lp_servicename(talloc_tos(), SNUM(conn)), destname ));
 
-       string_set(&conn->connectpath, destname);
-       SAFE_FREE(destname);
+       talloc_free(conn->connectpath);
+       conn->connectpath = destname;
        return true;
 }
 
@@ -867,7 +867,8 @@ static NTSTATUS make_connection_snum(struct 
smbd_server_connection *sconn,
        }
        conn->base_share_dev = smb_fname_cpath->st.st_ex_dev;
 
-       string_set(&conn->origpath,conn->connectpath);
+       talloc_free(conn->origpath);
+       conn->origpath = talloc_strdup(conn, conn->connectpath);
 
        /* Figure out the characteristics of the underlying filesystem. This
         * assumes that all the filesystem mounted withing a share path have
diff --git a/source3/wscript_build b/source3/wscript_build
index 40afdd7..9125667 100755
--- a/source3/wscript_build
+++ b/source3/wscript_build
@@ -1058,7 +1058,7 @@ bld.SAMBA3_SUBSYSTEM('tdb-wrap3',
                     vars=locals())
 
 bld.SAMBA3_LIBRARY('samba3-util',
-                   source='''lib/util_sec.c lib/util_str.c lib/adt_tree.c 
lib/util_malloc.c lib/memcache.c lib/string_init.c lib/namearray.c 
lib/file_id.c''',
+                   source='''lib/util_sec.c lib/util_str.c lib/adt_tree.c 
lib/util_malloc.c lib/memcache.c lib/namearray.c lib/file_id.c''',
                    deps='samba-util charset',
                    private_library=True)
 


-- 
Samba Shared Repository

Reply via email to