Giter Club home page Giter Club logo

Comments (2)

eboasson avatar eboasson commented on September 12, 2024

Good question ...

I think the double underscore is because Cyclone IDL compiler follows the mapping from IDL to C specified by the OMG (https://www.omg.org/spec/C/1.0/PDF from 1997 (!)) which states in section 1.8:

For types whose parameter passing modes require heap allocation, an ORB implementation will provide allocation functions. These types include variable-length struct, variable-length union, sequence, any, string, wstring and array of a variable-length type. The return value of these allocation functions must be freed using CORBA_free(). For one of these listed types T, the ORB implementation will provide the following type-specific allocation function:

T *T__alloc();

The functions are defined at global scope using the fully-scoped name of T converted into a C language name (as described in “Scoped Names” on page 1-5) followed by the suffix “__alloc” (note the double underscore). For any, string, and wstring, the allocation functions are:

CORBA_any *CORBA_any_alloc();
char *CORBA_string_alloc();
CORBA_wchar* CORBA_wstring_alloc(CORBA_unsigned_long len);

The free function in that spec is always CORBA_free (independent of the type). The DDS spec doesn't seem to say anything about how allocation and freeing is supposed to work, but the implication of the structure of all the specs is that it would be as prescribed by the spec I just quoted. So it should be CORBA_free! I know OpenSplice uses DDS_free, I have no clue what the others do.

In any case having a typed free function is therefore not following the spec, and it probably should have been a double underscore. For Cyclone, this behaviour was inherited from something way older, and I think changing it isn't worth the bother. Lost in the mists of time ...

(I usually don't bother using them. I usually just do a heap- or stack-allocation and memset it to 0, and call dds_sample_free(ptr, &topic_desc, DDS_FREE_CONTENTS_BIT) and then call free myself if I allocated with malloc.)

from cyclonedds.

tooyoungtoosimpo avatar tooyoungtoosimpo commented on September 12, 2024

Thanks for your answer, it helps me a lot.

from cyclonedds.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.