summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2006-11-08 21:18:24 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:25:23 -0500
commitd5314b9f3f8b27ea0f9efdf3fad27fd349a1adf3 (patch)
treeb88c9a4b6e8c96fa9412a23b0b98171a8000a3c9
parentbf16e43328f4e025a21c4ee2dc1d82f8e522362d (diff)
downloadsamba-d5314b9f3f8b27ea0f9efdf3fad27fd349a1adf3.tar.gz
samba-d5314b9f3f8b27ea0f9efdf3fad27fd349a1adf3.tar.bz2
samba-d5314b9f3f8b27ea0f9efdf3fad27fd349a1adf3.zip
r19638: convert resolve.c to the new composite api
metze (This used to be commit 617f9c70c1b61e0fd4338048bbd94e7a4722ad9d)
-rw-r--r--source4/libcli/resolve/resolve.c42
1 files changed, 19 insertions, 23 deletions
diff --git a/source4/libcli/resolve/resolve.c b/source4/libcli/resolve/resolve.c
index 8bacab8cd7..532cf19bb4 100644
--- a/source4/libcli/resolve/resolve.c
+++ b/source4/libcli/resolve/resolve.c
@@ -123,49 +123,45 @@ struct composite_context *resolve_name_send(struct nbt_name *name, struct event_
{
struct composite_context *c;
struct resolve_state *state;
- NTSTATUS status;
-
- c = talloc_zero(NULL, struct composite_context);
- if (c == NULL) goto failed;
-
- state = talloc(c, struct resolve_state);
- if (state == NULL) goto failed;
-
- status = nbt_name_dup(state, name, &state->name);
- if (!NT_STATUS_IS_OK(status)) goto failed;
- if (methods == NULL) goto failed;
- state->methods = str_list_copy(state, methods);
- if (state->methods == NULL) goto failed;
+ c = composite_create(event_ctx, event_ctx);
+ if (c == NULL) return NULL;
- c->state = COMPOSITE_STATE_IN_PROGRESS;
- c->private_data = state;
+ if (methods == NULL) {
+ composite_error(c, NT_STATUS_INVALID_PARAMETER);
+ return c;
+ }
if (event_ctx == NULL) {
c->event_ctx = event_context_init(c);
- if (c->event_ctx == NULL) goto failed;
-
} else {
c->event_ctx = talloc_reference(c, event_ctx);
}
+ if (composite_nomem(c->event_ctx, c)) return c;
+
+ state = talloc(c, struct resolve_state);
+ if (composite_nomem(state, c)) return c;
+ c->private_data = state;
+
+ c->status = nbt_name_dup(state, name, &state->name);
+ if (!composite_is_ok(c)) return c;
+
+ state->methods = str_list_copy(state, methods);
+ if (composite_nomem(state->methods, c)) return c;
if (is_ipaddress(state->name.name) ||
strcasecmp(state->name.name, "localhost") == 0) {
struct ipv4_addr ip = interpret_addr2(state->name.name);
state->reply_addr = talloc_strdup(state, sys_inet_ntoa(ip));
- if (!state->reply_addr) goto failed;
+ if (composite_nomem(state->reply_addr, c)) return c;
composite_done(c);
return c;
}
state->creq = setup_next_method(c);
- if (state->creq == NULL) goto failed;
+ if (composite_nomem(state->creq, c)) return c;
return c;
-
-failed:
- talloc_free(c);
- return NULL;
}
/*