Menu

#2142 imm: Compile the IMM library using the C++ compiler

5.2.FC
fixed
None
enhancement
imm
lib
minor
2016-12-12
2016-10-27
Hung Nguyen
No

Compile the IMM library using the C++ compiler and fix all errors that C++ compiler complains.

Related

Tickets: #2142

Discussion

  • Anders Widell

    Anders Widell - 2016-10-27

    Do you mean "compile the IMM library using the C++ compiler? In addition there are also parts of the IMM node director that ought to be converted to C++, so that we can get rid of the C<->C++ wrapper functions.

     
    • Zoran Milinkovic

      Hi Anders,

      The only thing I can see for switching to C++ is to replace patricia tree with some other C++ structure (possibly std::map).
      If you give me other advantages for switching from C to C++, I would be interested to hear them.

      How do you think to get rid of wrapper functions ?
      Most of wrapper functions are not just pure call of ImmModel methods.

      BR,
      Zoran

      -----Original Message-----
      From: Anders Widell [mailto:anders-w@users.sf.net]
      Sent: den 27 oktober 2016 14:56
      To: [opensaf:tickets] 2142@tickets.opensaf.p.re.sf.net
      Subject: [opensaf:tickets] #2142 imm: Use C++ for IMM library

      Do you mean "compile the IMM library using the C++ compiler? In addition there are also parts of the IMM node director that ought to be converted to C++, so that we can get rid of the C<->C++ wrapper functions.


      ** [tickets:#2142] imm: Use C++ for IMM library**

      Status: accepted
      Milestone: 5.2.FC
      Created: Thu Oct 27, 2016 04:31 AM UTC by Hung Nguyen Last Updated: Thu Oct 27, 2016 04:31 AM UTC
      Owner: Hung Nguyen

      Use c++ for imm library.


      Sent from sourceforge.net because you indicated interest in https://sourceforge.net/p/opensaf/tickets/2142/

      To unsubscribe from further messages, please visit https://sourceforge.net/auth/subscriptions/

       

      Related

      Tickets: #2142

    • Hung Nguyen

      Hung Nguyen - 2016-10-28

      Yes, this ticket is to use c++ compiler to complie the library and fix all the errors that c++ compiler complains since c++ compiler is stricter than c compiler.

      Further enhancements like replacing patricia trees will be done in other tickets, not this one.
      Changing the ticket title to avoid confusion.

       
  • Anders Widell

    Anders Widell - 2016-10-27

    I would really like to get rid of the C<->C++ wrapper functions, that look for example like this:

    void
    immModel_getNonCriticalCcbs(IMMND_CB *cb,
        SaUint32T** ccbIdArr,
        SaUint32T* ccbIdArrSize)
    {
        IdVector ccbs;
        IdVector::iterator ix2;
        unsigned int ix;
    
        ImmModel::instance(&cb->immModel)->getNonCriticalCcbs(ccbs);
        *ccbIdArrSize = (SaUint32T) ccbs.size();
        if(*ccbIdArrSize) {
            *ccbIdArr = (SaUint32T *) malloc((*ccbIdArrSize) * sizeof(SaUint32T));
    
            for(ix2=ccbs.begin(), ix=0;
                ix2!=ccbs.end();
                ++ix2, ++ix) {
                (*ccbIdArr)[ix] = (*ix2);
            }
            osafassert(ix==(*ccbIdArrSize));
        }
    }
    
     
  • Anders Widell

    Anders Widell - 2016-10-27

    Unless it is obvious from the example above why removing them would be a good thing, I can list some of the reasons:

    • The wrappper functions are just clutter - they wouldn't be needed if we use C++ all over
    • They cost performance and extra memory in cases like the one in the example, since it has to make a deep copy of the data structures.
    • The C-version of the API is more error-prone; for example there is a risk for memory leaks since you can forget to free the memory that was allocated using malloc().

    The wrapper functions ought to be a pure and simple conversion between C and C++. If the wrapper function does something extra that the C++ doesn't do then there is a problem with readability - I wouldn't expect this.

     
  • Hung Nguyen

    Hung Nguyen - 2016-10-28
    • summary: imm: Use C++ for IMM library --> imm: Compile the IMM library using the C++ compiler
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -1 +1 @@
    -Use c++ for imm library.
    +Compile the IMM library using the C++ compiler and fix all errors that C++ compiler complains.
    
     
  • Hung Nguyen

    Hung Nguyen - 2016-11-03
    • status: accepted --> review
     
  • Hung Nguyen

    Hung Nguyen - 2016-12-12
    • status: review --> fixed
     

Log in to post a comment.