axl main logo
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Modules Pages
axlNode * axl_node_create_ref ( char *  name)

Creates a new axlNode but reusing the memory passed in by the name reference.

This function works the same way like axl_node_create, but previous one makes a local copy from the name provided. This means that, if you have allocated the reference being passed, the previous function will allocate again memory for the name reference.

Obviously, for a few xml nodes this have none or little effect but, if your xml document have 100.000 nodes you save 100.000 extra memory allocations and deallocations. This may improve your application performace because memory fragmentation/allocations/deallocations are reduced.

Keep in mind that this function should not be used with static strings. Example:

1 // propery node creation
2 axlNode * node = axl_node_create ("test");
4 // NOT PROPER node creation
5 axlNode * node = axl_node_create_ref ("test");
nameA user-space allocated memory representing the node name. The function doesn't check if the parameter received is null.
A newly created axlNode reference that must be deallocated by axl_node_free.

References axl_new.