MCPcopy Create free account
hub / github.com/acl-dev/acl / tpl_set_section_ex

Function tpl_set_section_ex

app/wizard/tpllib.cpp:910–970  ·  view source on GitHub ↗

Set or replace added content in section with supplied value */

Source from the content-addressed store, hash-verified

908
909/* Set or replace added content in section with supplied value */
910static int tpl_set_section_ex(tpl_t* tpl,
911 const char* key,
912 const char* val,
913 int len,
914 tpl_node_t *existing_node)
915{
916 tpl_tcell_t *section = tpl_get_section(tpl->tpl, key);
917
918 if (section != NULL)
919 {
920 if (section->tpl->first != NULL
921 || section->tpl->head == NULL
922 || section->tpl->head->next != NULL
923 || section->tpl->head->len != len)
924 {
925 /* Destroy the contents of this section */
926 tpl_release(section->tpl);
927 tpl_init(section->tpl);
928
929 section->tpl->parent = tpl->tpl;
930 section->tpl->head = create_node(len);
931 }
932
933 (void)memcpy(section->tpl->head->val, val, len);
934 section->tpl->head->val[len] = 0;
935
936 if (existing_node != NULL)
937 {
938 existing_node->next = section->tpl->added_head;
939 section->tpl->added_head = existing_node;
940 }
941 else
942 {
943 if (section->tpl->added_head != NULL
944 && section->tpl->added_head->len != len)
945 {
946 tpl_node_t *node = create_node(len);
947 node->next = section->tpl->added_head;
948 section->tpl->added_head = node;
949 }
950 else if (section->tpl->added_head == NULL)
951 section->tpl->added_head = create_node(len);
952
953 (void)memcpy(section->tpl->added_head->val, val, len);
954 section->tpl->added_head->val[len] = 0;
955 }
956
957 while (section->tpl->added_head->next != NULL)
958 {
959 tpl_node_t *deleted = section->tpl->added_head->next;
960 section->tpl->added_head->next = deleted->next;
961 destroy_node(deleted);
962 }
963
964 section->tpl->added_tail = &section->tpl->added_head->next;
965
966 return TPL_OK;
967 }

Callers 2

tpl_set_sectionFunction · 0.70

Calls 5

memcpyFunction · 0.85
tpl_releaseFunction · 0.70
tpl_initFunction · 0.70
create_nodeFunction · 0.70
destroy_nodeFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…