Software Development Kit (SDK) and API Discussions

Question about Core API function na_child_add() and na_elem_free()

eshropshire
2,395 Views

Assuming that I have done the following:

na_elem_t   *pElem1 = NULL;

na_elem_t   *pElem2 = NULL;

na_elem_t   *pElem3 = NULL;

pElem1 = na_elem_new("Element #1");

pElem2 = na_elem_new("Element #2");

pElem3 = na_child_add(pElem1, pElem2);

I then note that pElem3 == pElem2.

Is it safe to assume that I only need to call na_elem_free() for pElem1 at this point because element #1 now "owns" the memory that was allocated to element #2, and calling na_elem_free() for element #1 will result in freeing the memory for both element #1 and element #2?

1 ACCEPTED SOLUTION

rkiran
2,395 Views

Yes, you just need to call na_elem_free() for element #1 that will result in freeing the memory for both element #1 and element #2.

View solution in original post

1 REPLY 1

rkiran
2,396 Views

Yes, you just need to call na_elem_free() for element #1 that will result in freeing the memory for both element #1 and element #2.

Public