source3/smbd/conn.c: wean off string_set/string_free
authorRusty Russell <rusty@rustcorp.com.au>
Mon, 23 Jul 2012 05:21:34 +0000 (14:51 +0930)
committerAndrew Bartlett <abartlet@samba.org>
Tue, 7 Aug 2012 13:20:05 +0000 (23:20 +1000)
Use straight talloc strings.  This is the only user outside loadparm.c.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
source3/smbd/conn.c
source3/smbd/service.c

index 28e1850b45009e61bc5afe064c57d54f323a7961..bc5a03b4eb09034d59d538d1ee9f783fef42a106 100644 (file)
@@ -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);
 }
index a1d009cb44e537cb660bd4fec24a840307e6643f..4fc1aa3e2dde74f57b3167fbeca4ba66d554eb80 100644 (file)
@@ -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