Changeset 8ca26d5 for libcfa/src/stdlib.cfa
- Timestamp:
- Nov 12, 2020, 1:26:38 PM (3 years ago)
- 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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/stdlib.cfa
r3746f777 r8ca26d5 10 10 // Created On : Thu Jan 28 17:10:29 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Jul 19 15:05:28202013 // Update Count : 50 112 // Last Modified On : Thu Nov 12 07:46:09 2020 13 // Update Count : 503 14 14 // 15 15 … … 26 26 //--------------------------------------- 27 27 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 30 forall( dtype T | sized(T), ttype TT | { void ?{}( T &, TT ); } ) 31 T * anew( size_t dim, TT p ) { 52 32 T * arr = alloc( dim ); 53 33 for ( unsigned int i = 0; i < dim; i += 1 ) { … … 68 48 } // adelete 69 49 70 forall( dtype T | sized(T) | { void ^?{}( T & ); }, ttype Params | { void adelete( Params); } )71 void adelete( T arr[], Paramsrest ) {50 forall( dtype T | sized(T) | { void ^?{}( T & ); }, ttype TT | { void adelete( TT ); } ) 51 void adelete( T arr[], TT rest ) { 72 52 if ( arr ) { // ignore null 73 53 size_t dim = malloc_size( arr ) / sizeof( T );
Note: See TracChangeset
for help on using the changeset viewer.