Ignore:
Timestamp:
Aug 23, 2017, 6:22:07 PM (8 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
87e08e24, cb811ac
Parents:
9f07232 (diff), bd37119 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of plg2:software/cfa/cfa-cc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/libcfa/stdlib.c

    r9f07232 rd3e4d6c  
    3232        if ( nlen > olen ) {                                                            // larger ?
    3333                memset( nptr + olen, (int)fill, nlen - olen );  // initialize added storage
    34         } // 
     34        } //
    3535    return (T *)nptr;
    3636} // alloc
    3737
    3838// allocation/deallocation and constructor/destructor, non-array types
    39 forall( dtype T | sized(T), ttype Params | { void ?{}( T *, Params ); } )
     39forall( dtype T | sized(T), ttype Params | { void ?{}( T &, Params ); } )
    4040T * new( Params p ) {
    41         return (malloc()){ p };                                                         // run constructor
     41        return &(*malloc()){ p };                                                               // run constructor
    4242} // new
    4343
    44 forall( dtype T | { void ^?{}( T * ); } )
     44forall( dtype T | sized(T) | { void ^?{}( T & ); } )
    4545void delete( T * ptr ) {
    4646        if ( ptr ) {                                                                            // ignore null
    47                 ^ptr{};                                                                                 // run destructor
     47                ^(*ptr){};                                                                                      // run destructor
    4848                free( ptr );
    4949        } // if
    5050} // delete
    5151
    52 forall( dtype T, ttype Params | { void ^?{}( T * ); void delete( Params ); } )
     52forall( dtype T, ttype Params | sized(T) | { void ^?{}( T & ); void delete( Params ); } )
    5353void delete( T * ptr, Params rest ) {
    5454        if ( ptr ) {                                                                            // ignore null
    55                 ^ptr{};                                                                                 // run destructor
     55                ^(*ptr){};                                                                                      // run destructor
    5656                free( ptr );
    5757        } // if
     
    6161
    6262// allocation/deallocation and constructor/destructor, array types
    63 forall( dtype T | sized(T), ttype Params | { void ?{}( T *, Params ); } )
     63forall( dtype T | sized(T), ttype Params | { void ?{}( T &, Params ); } )
    6464T * anew( size_t dim, Params p ) {
    6565        T *arr = alloc( dim );
    6666        for ( unsigned int i = 0; i < dim; i += 1 ) {
    67                 (&arr[i]){ p };                                                                 // run constructor
     67                (arr[i]){ p };                                                                  // run constructor
    6868        } // for
    6969        return arr;
    7070} // anew
    7171
    72 forall( dtype T | sized(T) | { void ^?{}( T * ); } )
     72forall( dtype T | sized(T) | { void ^?{}( T & ); } )
    7373void adelete( size_t dim, T arr[] ) {
    7474        if ( arr ) {                                                                            // ignore null
    7575                for ( int i = dim - 1; i >= 0; i -= 1 ) {               // reverse allocation order, must be unsigned
    76                         ^(&arr[i]){};                                                           // run destructor
     76                        ^(arr[i]){};                                                            // run destructor
    7777                } // for
    7878                free( arr );
     
    8080} // adelete
    8181
    82 forall( dtype T | sized(T) | { void ^?{}( T * ); }, ttype Params | { void adelete( Params ); } )
     82forall( dtype T | sized(T) | { void ^?{}( T & ); }, ttype Params | { void adelete( Params ); } )
    8383void adelete( size_t dim, T arr[], Params rest ) {
    8484        if ( arr ) {                                                                            // ignore null
    8585                for ( int i = dim - 1; i >= 0; i -= 1 ) {               // reverse allocation order, must be unsigned
    86                         ^(&arr[i]){};                                                           // run destructor
     86                        ^(arr[i]){};                                                            // run destructor
    8787                } // for
    8888                free( arr );
Note: See TracChangeset for help on using the changeset viewer.