summaryrefslogtreecommitdiff
path: root/source4/libcli/raw/clisocket.c
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2004-08-21 07:43:29 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:58:14 -0500
commitb7e1ea20dc873a753ff64653987130f03897a4e9 (patch)
tree67f37a1a19113c622dedf942f39b27ca994c1b05 /source4/libcli/raw/clisocket.c
parentb45f4ebbb880e41abf86abb54264123f3edbde05 (diff)
downloadsamba-b7e1ea20dc873a753ff64653987130f03897a4e9.tar.gz
samba-b7e1ea20dc873a753ff64653987130f03897a4e9.tar.bz2
samba-b7e1ea20dc873a753ff64653987130f03897a4e9.zip
r1985: take advantage of the new talloc in a few more places
(This used to be commit 6ffdfd779936ce8c5ca49c5f444e8da2bbeee0a8)
Diffstat (limited to 'source4/libcli/raw/clisocket.c')
-rw-r--r--source4/libcli/raw/clisocket.c23
1 files changed, 7 insertions, 16 deletions
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;
}