libyang  1.0.253
YANG data modeling language library
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
Dictionary

Functions

const char * lydict_insert (struct ly_ctx *ctx, const char *value, size_t len)
 Insert string into dictionary. If the string is already present, only a reference counter is incremented and no memory allocation is performed. More...
 
const char * lydict_insert_zc (struct ly_ctx *ctx, char *value)
 Insert string into dictionary - zerocopy version. If the string is already present, only a reference counter is incremented and no memory allocation is performed. This insert function variant avoids duplication of specified value - it is inserted into the dictionary directly. More...
 
void lydict_remove (struct ly_ctx *ctx, const char *value)
 Remove specified string from the dictionary. It decrement reference counter for the string and if it is zero, the string itself is freed. More...
 

Detailed Description

Publicly visible functions and values of the libyang dictionary. They provide access to the strings stored in the libyang context.

Function Documentation

const char* lydict_insert ( struct ly_ctx *  ctx,
const char *  value,
size_t  len 
)

Insert string into dictionary. If the string is already present, only a reference counter is incremented and no memory allocation is performed.

Parameters
[in]ctxlibyang context handler
[in]valueString to be stored in the dictionary.
[in]lenNumber of bytes to store. The value is not required to be NULL terminated string, the len parameter says number of bytes stored in dictionary. The specified number of bytes is duplicated and terminating NULL byte is added automatically.
Returns
pointer to the string stored in the dictionary
const char* lydict_insert_zc ( struct ly_ctx *  ctx,
char *  value 
)

Insert string into dictionary - zerocopy version. If the string is already present, only a reference counter is incremented and no memory allocation is performed. This insert function variant avoids duplication of specified value - it is inserted into the dictionary directly.

Parameters
[in]ctxlibyang context handler
[in]valueNULL-terminated string to be stored in the dictionary. If the string is not present in dictionary, the pointer is directly used by the dictionary. Otherwise, the reference counter is incremented and the value is freed. So, after calling the function, caller is supposed to not use the value address anymore.
Returns
pointer to the string stored in the dictionary
void lydict_remove ( struct ly_ctx *  ctx,
const char *  value 
)

Remove specified string from the dictionary. It decrement reference counter for the string and if it is zero, the string itself is freed.

Parameters
[in]ctxlibyang context handler
[in]valueString to be freed. Note, that not only the string itself must match the stored value, but also the address is being compared and the counter is decremented only if it matches.