MCPcopy Create free account
hub / github.com/Kitware/VTK / xmlDOMWrapNsMapAddItem

Function xmlDOMWrapNsMapAddItem

ThirdParty/libxml2/vtklibxml2/tree.c:7880–7948  ·  view source on GitHub ↗

* xmlDOMWrapNsMapAddItem: * @map: the ns-map * @oldNs: the old ns-struct * @newNs: the new ns-struct * @depth: depth and ns-kind information * * Adds an ns-mapping item. */

Source from the content-addressed store, hash-verified

7878* Adds an ns-mapping item.
7879*/
7880static xmlNsMapItemPtr
7881xmlDOMWrapNsMapAddItem(xmlNsMapPtr *nsmap, int position,
7882 xmlNsPtr oldNs, xmlNsPtr newNs, int depth)
7883{
7884 xmlNsMapItemPtr ret;
7885 xmlNsMapPtr map;
7886
7887 if (nsmap == NULL)
7888 return(NULL);
7889 if ((position != -1) && (position != 0))
7890 return(NULL);
7891 map = *nsmap;
7892
7893 if (map == NULL) {
7894 /*
7895 * Create the ns-map.
7896 */
7897 map = (xmlNsMapPtr) xmlMalloc(sizeof(struct xmlNsMap));
7898 if (map == NULL)
7899 return(NULL);
7900 memset(map, 0, sizeof(struct xmlNsMap));
7901 *nsmap = map;
7902 }
7903
7904 if (map->pool != NULL) {
7905 /*
7906 * Reuse an item from the pool.
7907 */
7908 ret = map->pool;
7909 map->pool = ret->next;
7910 memset(ret, 0, sizeof(struct xmlNsMapItem));
7911 } else {
7912 /*
7913 * Create a new item.
7914 */
7915 ret = (xmlNsMapItemPtr) xmlMalloc(sizeof(struct xmlNsMapItem));
7916 if (ret == NULL)
7917 return(NULL);
7918 memset(ret, 0, sizeof(struct xmlNsMapItem));
7919 }
7920
7921 if (map->first == NULL) {
7922 /*
7923 * First ever.
7924 */
7925 map->first = ret;
7926 map->last = ret;
7927 } else if (position == -1) {
7928 /*
7929 * Append.
7930 */
7931 ret->prev = map->last;
7932 map->last->next = ret;
7933 map->last = ret;
7934 } else if (position == 0) {
7935 /*
7936 * Set on first position.
7937 */

Calls

no outgoing calls

Tested by

no test coverage detected