Changeset 91


Ignore:
Timestamp:
07/02/13 22:29:54 (11 years ago)
Author:
Maciej Komosinski
Message:

better and simpler memory management (allocation/deallocation); malloc/free -> new[]/delete[]

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpp/gdk/paramobj.cpp

    r81 r91  
    9494int n=tab->flags;
    9595if (!n) return 0;
    96 ExtValue *ret,*v;
    97 ret=v=(ExtValue*)malloc( sizeof(ExtValue)*(n+1) );
    98 for (int i=0;i<=n;i++,v++)
    99         new(v) ExtValue;
     96ExtValue *ret=new ExtValue[n+1];
    10097ret->setInt(n);
    101 v=ret+1;
     98ExtValue *v=ret+1;
    10299tab+=tab->group;
    103100for (;n>0;n--,v++,tab++)
     
    126123void* ParamObject::dupObject(void* src)
    127124{
    128 if (!src) return 0;
     125if (!src) return NULL;
    129126ExtValue *s=(ExtValue *)src;
    130127int n=s->getInt();
     
    144141{
    145142if (!obj) return;
    146 ExtValue *o=(ExtValue *)obj,*t=o+1;
    147 int n=o->getInt();
    148 for (int i=0;i<n;i++,t++)
    149         t -> ~ExtValue();
    150 free(obj);
     143delete[] (ExtValue *)obj;
    151144}
    152145
Note: See TracChangeset for help on using the changeset viewer.