libyang  2.2.8
libyang is YANG data modelling language parser and toolkit written (and providing API) in C.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
tree_edit.h File Reference

libyang generic macros and functions to modify YANG schema or data trees. Intended for internal use and libyang plugins. More...

#include <stdlib.h>
Include dependency graph for tree_edit.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define LOGMEM(CTX)
 
#define LY_ARRAY_CREATE(CTX, ARRAY, SIZE, EACTION)
 Allocate a (sized array) for the specified number of items. If the ARRAY already exists, it is resized (space for SIZE items is added and zeroed). More...
 
#define LY_ARRAY_CREATE_GOTO(CTX, ARRAY, SIZE, RET, GOTO)   LY_ARRAY_CREATE(CTX, ARRAY, SIZE, RET = LY_EMEM; goto GOTO)
 Allocate a (sized array) for the specified number of items. If the ARRAY already exists, it is resized (space for SIZE items is added). More...
 
#define LY_ARRAY_CREATE_RET(CTX, ARRAY, SIZE, RETVAL)   LY_ARRAY_CREATE(CTX, ARRAY, SIZE, return RETVAL)
 Allocate a (sized array) for the specified number of items. If the ARRAY already exists, it is resized (space for SIZE items is added and zeroed). More...
 
#define LY_ARRAY_DECREMENT(ARRAY)   --(*((LY_ARRAY_COUNT_TYPE*)(ARRAY) - 1))
 Decrement the items counter in a (sized array). More...
 
#define LY_ARRAY_DECREMENT_FREE(ARRAY)
 Decrement the items counter in a (sized array) and free the whole array in case it was decremented to 0. More...
 
#define LY_ARRAY_FREE(ARRAY)   if (ARRAY){free((LY_ARRAY_COUNT_TYPE*)(ARRAY) - 1);}
 Free the space allocated for the (sized array). More...
 
#define LY_ARRAY_INCREMENT(ARRAY)   ++(*((LY_ARRAY_COUNT_TYPE*)(ARRAY) - 1))
 Increment the items counter in a (sized array). More...
 
#define LY_ARRAY_NEW(CTX, ARRAY, EACTION)
 (Re-)Allocation of a (sized array). More...
 
#define LY_ARRAY_NEW_GOTO(CTX, ARRAY, NEW_ITEM, RET, GOTO)
 (Re-)Allocation of a (sized array). More...
 
#define LY_ARRAY_NEW_RET(CTX, ARRAY, NEW_ITEM, RETVAL)
 (Re-)Allocation of a (sized array). More...
 
#define LY_ARRAY_REMOVE_VALUE(ARRAY, VALUE)
 Remove item from array based on value. More...
 
#define LY_LIST_INSERT(LIST, NEW_ITEM, LINKER)
 Insert item into linked list. More...
 
#define LY_LIST_NEW(CTX, LIST, NEW_ITEM, LINKER, EACTION)
 Allocate and insert new item into linked list, return in case of error. More...
 
#define LY_LIST_NEW_GOTO(CTX, LIST, NEW_ITEM, LINKER, RET, LABEL)   LY_LIST_NEW(CTX, LIST, NEW_ITEM, LINKER, RET = LY_EMEM; goto LABEL)
 Allocate and insert new item into linked list, goto specified label in case of error. More...
 
#define LY_LIST_NEW_RET(CTX, LIST, NEW_ITEM, LINKER, RETVAL)   LY_LIST_NEW(CTX, LIST, NEW_ITEM, LINKER, return RETVAL)
 Allocate and insert new item into linked list, return in case of error. More...
 

Functions

void * ly_realloc (void *ptr, size_t size)
 Wrapper for realloc() call. The only difference is that if it fails to allocate the requested memory, the original memory is freed as well. More...
 

Detailed Description

libyang generic macros and functions to modify YANG schema or data trees. Intended for internal use and libyang plugins.

Author
Radek Krejci rkrej.nosp@m.ci@c.nosp@m.esnet.nosp@m..cz Copyright (c) 2019-2021 CESNET, z.s.p.o.

This source code is licensed under BSD 3-Clause License (the "License"). You may not use this file except in compliance with the License. You may obtain a copy of the License at

https://opensource.org/licenses/BSD-3-Clause

Definition in file tree_edit.h.

Macro Definition Documentation

#define LOGMEM (   CTX)

Definition at line 22 of file tree_edit.h.

Function Documentation

void* ly_realloc ( void *  ptr,
size_t  size 
)

Wrapper for realloc() call. The only difference is that if it fails to allocate the requested memory, the original memory is freed as well.

Parameters
[in]ptrMemory to reallocate.
[in]sizeNew size of the memory block.
Returns
Pointer to the new memory, NULL on error.