[PATCH] Use talloc_autofree_context() to allocate global memory
Stefan (metze) Metzmacher
metze at samba.org
Fri Sep 12 04:28:58 MDT 2014
Hi Kamen,
> --- a/lib/util/debug_s3.c
> +++ b/lib/util/debug_s3.c
> @@ -84,10 +84,19 @@ static void debuglevel_message(struct messaging_context *msg_ctx,
> struct server_id src,
> DATA_BLOB *data)
> {
> - char *message = debug_list_class_names_and_levels();
> + char *message;
> + TALLOC_CTX *temp_ctx;
>
> + temp_ctx = talloc_new(NULL);
> + if (temp_ctx == NULL) {
> + DEBUG(0,("debuglevel_message - Unable to allocate local mem context. Possibly OOM!\n"));
> + return;
> + }
Wouldn't it be better to use talloc_stackframe() here?
> + message = debug_list_class_names_and_levels(temp_ctx);
> if (!message) {
> DEBUG(0,("debuglevel_message - debug_list_class_names_and_levels returned NULL\n"));
> + TALLOC_FREE(temp_ctx);
> return;
> }
metze
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: OpenPGP digital signature
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20140912/d65b49b6/attachment.pgp>
More information about the samba-technical
mailing list