From b7e1ea20dc873a753ff64653987130f03897a4e9 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 21 Aug 2004 07:43:29 +0000 Subject: r1985: take advantage of the new talloc in a few more places (This used to be commit 6ffdfd779936ce8c5ca49c5f444e8da2bbeee0a8) --- source4/libcli/raw/clisocket.c | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) (limited to 'source4/libcli/raw/clisocket.c') diff --git a/source4/libcli/raw/clisocket.c b/source4/libcli/raw/clisocket.c index 2bb50d200f..94bb447f47 100644 --- a/source4/libcli/raw/clisocket.c +++ b/source4/libcli/raw/clisocket.c @@ -28,18 +28,13 @@ struct smbcli_socket *smbcli_sock_init(void) { struct smbcli_socket *sock; - TALLOC_CTX *mem_ctx; - mem_ctx = talloc_init("smbcli_socket"); - if (!mem_ctx) return NULL; - - sock = talloc_zero(mem_ctx, sizeof(*sock)); + sock = talloc_named(NULL, sizeof(*sock), "smbcli_socket"); if (!sock) { - talloc_destroy(mem_ctx); return NULL; } - sock->mem_ctx = mem_ctx; + ZERO_STRUCTP(sock); sock->fd = -1; sock->port = 0; /* 20 second default timeout */ @@ -153,7 +148,6 @@ BOOL smbcli_sock_connect_byname(struct smbcli_socket *sock, const char *host, in { int name_type = 0x20; struct in_addr ip; - TALLOC_CTX *mem_ctx; char *name, *p; BOOL ret; @@ -162,10 +156,7 @@ BOOL smbcli_sock_connect_byname(struct smbcli_socket *sock, const char *host, in return sock->fd != -1; } - mem_ctx = talloc_init("smbcli_sock_connect_byname"); - if (!mem_ctx) return False; - - name = talloc_strdup(mem_ctx, host); + name = talloc_strdup(sock, host); /* allow hostnames of the form NAME#xx and do a netbios lookup */ if ((p = strchr(name, '#'))) { @@ -173,18 +164,18 @@ BOOL smbcli_sock_connect_byname(struct smbcli_socket *sock, const char *host, in *p = 0; } - if (!resolve_name(mem_ctx, name, &ip, name_type)) { - talloc_destroy(mem_ctx); + if (!resolve_name(name, name, &ip, name_type)) { + talloc_free(name); return False; } ret = smbcli_sock_connect(sock, &ip, port); if (ret) { - sock->hostname = talloc_steal(sock->mem_ctx, name); + sock->hostname = talloc_steal(sock, name); } - talloc_destroy(mem_ctx); + talloc_destroy(name); return ret; } -- cgit