Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

libtalloc_stealing(3) [centos man page]

libtalloc_stealing(3)						      talloc						     libtalloc_stealing(3)

NAME
libtalloc_stealing - Chapter 2: Stealing a context Stealing a context Talloc has the ability to change the parent of a talloc context to another one. This operation is commonly referred to as stealing and it is one of the most important actions performed with talloc contexts. Stealing a context is necessary if we want the pointer to outlive the context it is created on. This has many possible use cases, for instance stealing a result of a database search to an in-memory cache context, changing the parent of a field of a generic structure to a more specific one or vice-versa. The most common scenario, at least in Samba, is to steal output data from a function-specific context to the output context given as an argument of that function. struct foo { char *a1; char *a2; char *a3; }; struct bar { char *wurst; struct foo *foo; }; struct foo *foo = talloc_zero(ctx, struct foo); foo->a1 = talloc_strdup(foo, "a1"); foo->a2 = talloc_strdup(foo, "a2"); foo->a3 = talloc_strdup(foo, "a3"); struct bar *bar = talloc_zero(NULL, struct bar); /* change parent of foo from ctx to bar */ bar->foo = talloc_steal(bar, foo); /* or do the same but assign foo = NULL */ bar->foo = talloc_move(bar, &foo); The talloc_move() function is similar to the talloc_steal() function but additionally sets the source pointer to NULL. In general, the source pointer itself is not changed (it only replaces the parent in the meta data). But the common usage is that the result is assigned to another variable, thus further accessing the pointer from the original variable should be avoided unless it is necessary. In this case talloc_move() is the preferred way of stealing a context. Additionally sets the source pointer to NULL, thus.protects the pointer from being accidentally freed and accessed using the old variable after its parent has been changed. Version 2.0 Tue Jun 17 2014 libtalloc_stealing(3)

Check Out this Related Man Page

Mojo::Parameters(3pm)					User Contributed Perl Documentation				     Mojo::Parameters(3pm)

NAME
Mojo::Parameters - Parameter container SYNOPSIS
use Mojo::Parameters; my $p = Mojo::Parameters->new(foo => 'bar', baz => 23); DESCRIPTION
Mojo::Parameters is a container for form parameters. ATTRIBUTES
Mojo::Parameters implements the following attributes. "charset" my $charset = $p->charset; $p = $p->charset('UTF-8'); Charset used for decoding parameters, defaults to "UTF-8". "pair_separator" my $separator = $p->pair_separator; $p = $p->pair_separator(';'); Separator for parameter pairs, defaults to "&". METHODS
Mojo::Parameters inherits all methods from Mojo::Base and implements the following new ones. "new" my $p = Mojo::Parameters->new; my $p = Mojo::Parameters->new('foo=b%3Bar&baz=23'); my $p = Mojo::Parameters->new(foo => 'b;ar'); my $p = Mojo::Parameters->new(foo => ['ba;r', 'b;az']); my $p = Mojo::Parameters->new(foo => ['ba;r', 'b;az'], bar => 23); Construct a new Mojo::Parameters object. "append" $p = $p->append(foo => 'ba;r'); $p = $p->append(foo => ['ba;r', 'b;az']); $p = $p->append(foo => ['ba;r', 'b;az'], bar => 23); Append parameters. # "foo=bar&foo=baz" Mojo::Parameters->new('foo=bar')->append(foo => 'baz'); # "foo=bar&foo=baz&foo=yada" Mojo::Parameters->new('foo=bar')->append(foo => ['baz', 'yada']); # "foo=bar&foo=baz&foo=yada&bar=23" Mojo::Parameters->new('foo=bar')->append(foo => ['baz', 'yada'], bar => 23); "clone" my $p2 = $p->clone; Clone parameters. "merge" $p = $p->merge(Mojo::Parameters->new(foo => 'b;ar', baz => 23)); Merge parameters. "param" my @names = $p->param; my $foo = $p->param('foo'); my @foo = $p->param('foo'); my $foo = $p->param(foo => 'ba;r'); my @foo = $p->param(foo => qw(ba;r ba;z)); Check and replace parameter values. "params" my $params = $p->params; $p = $p->params([foo => 'b;ar', baz => 23]); Parsed parameters. "parse" $p = $p->parse('foo=b%3Bar&baz=23'); Parse parameters. "remove" $p = $p->remove('foo'); Remove parameters. # "bar=yada" Mojo::Parameters->new('foo=bar&foo=baz&bar=yada')->remove('foo'); "to_hash" my $hash = $p->to_hash; Turn parameters into a hash reference. # "baz" Mojo::Parameters->new('foo=bar&foo=baz')->to_hash->{foo}[1]; "to_string" my $string = $p->to_string; Turn parameters into a string. SEE ALSO
Mojolicious, Mojolicious::Guides, <http://mojolicio.us>. perl v5.14.2 2012-09-05 Mojo::Parameters(3pm)
Man Page