ZettaScale Knowledge Base ZettaScale Knowledge Base

  • Home
  • DDS Products
    • DDS Overview and Concepts
    • OpenSplice DDS
      • OpenSplice DDS
        • OpenSplice FAQ
        • Why OpenSplice DDS?
        • Installation
          • OpenSplice Licensing FAQ
        • Best Practice and Possible Errors
        • API and IDL
        • Configuration
        • Networking
          • DDSI
          • RT Networking
        • Durability Service
        • DDS Security
        • Logging
        • Databases and DBMS
        • Release Notes
      • OpenSplice Tools
        • Overview
        • OpenSplice Launcher
        • OpenSplice Tuner
        • OpenSplice Tester
        • Record and Replay Manager
        • MMStat
    • Cyclone DDS
  • Zenoh
  • Contact Support
Home / DDS, OpenSplice DDS, API and IDL / Freeing sequences using C API in OpenSplice DDS

Freeing sequences using C API in OpenSplice DDS

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)

Related

DDSOpenSplice DDSAPI and IDL
twitter logo linkedin logo
News and Events
Copyright © 2022 ZettaScale Technology Ltd. All Rights Reserved