Ignore:
Timestamp:
Nov 12, 2020, 1:26:38 PM (3 years ago)
Author:
Fangren Yu <f37yu@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
0989e79, 9d264e18, f2ccbfd
Parents:
3746f777 (diff), 0b996a1 (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 plg.uwaterloo.ca:software/cfa/cfa-cc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/stdlib.cfa

    r3746f777 r8ca26d5  
    1010// Created On       : Thu Jan 28 17:10:29 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun Jul 19 15:05:28 2020
    13 // Update Count     : 501
     12// Last Modified On : Thu Nov 12 07:46:09 2020
     13// Update Count     : 503
    1414//
    1515
     
    2626//---------------------------------------
    2727
    28 // allocation/deallocation and constructor/destructor, non-array types
    29 forall( dtype T | sized(T), ttype Params | { void ?{}( T &, Params ); } )
    30 T * new( Params p ) {
    31         return &(*malloc()){ p };                                                       // run constructor
    32 } // new
    33 
    34 forall( dtype T | { void ^?{}( T & ); } )
    35 void delete( T * ptr ) {
    36         if ( ptr ) {                                                                            // ignore null
    37                 ^(*ptr){};                                                                              // run destructor
    38                 free( ptr );
    39         } // if
    40 } // delete
    41 
    42 forall( dtype T, ttype Params | { void ^?{}( T & ); void delete( Params ); } )
    43 void delete( T * ptr, Params rest ) {
    44         delete( ptr );
    45         delete( rest );
    46 } // delete
    47 
    48 
    49 // allocation/deallocation and constructor/destructor, array types
    50 forall( dtype T | sized(T), ttype Params | { void ?{}( T &, Params ); } )
    51 T * anew( size_t dim, Params p ) {
     28// Cforall allocation/deallocation and constructor/destructor, array types
     29
     30forall( dtype T | sized(T), ttype TT | { void ?{}( T &, TT ); } )
     31T * anew( size_t dim, TT p ) {
    5232        T * arr = alloc( dim );
    5333        for ( unsigned int i = 0; i < dim; i += 1 ) {
     
    6848} // adelete
    6949
    70 forall( dtype T | sized(T) | { void ^?{}( T & ); }, ttype Params | { void adelete( Params ); } )
    71 void adelete( T arr[], Params rest ) {
     50forall( dtype T | sized(T) | { void ^?{}( T & ); }, ttype TT | { void adelete( TT ); } )
     51void adelete( T arr[], TT rest ) {
    7252        if ( arr ) {                                                                            // ignore null
    7353                size_t dim = malloc_size( arr ) / sizeof( T );
Note: See TracChangeset for help on using the changeset viewer.