Every DDS object allocated by an __alloc() operation must be released by using the DDS_free() operation.
The example below shows how this works for a sequence.
Declaration on Heap
1 DDS_StringSeq* query_parameters;
2
3 query_parameters = DDS_StringSeq__alloc();
4 query_parameters-buffer = DDS_StringSeq_allocbuf (1);
5 query_parameters-buffer[0] = DDS_string_alloc (3);
6 sprintf (query_parameters-buffer[0], “%d”, numExe);
7
8 (usage?)
9
10 DDS_free (query_parameters);
The DDS_free method works recursively so DDS_free (query_parameters) frees everything allocated in that structure there is no need to free the buffer fields then.
DDS_free (query_parameters-buffer[0]); // not required
DDS_free (query_parameters-buffer); // not required
Declaration on Stack
If query_parameters were declared on stack and not as a pointer, e.g. DDS_StringSeq query_parameters then the following free is needed instead
DDS_free (query_parameters-buffer)