Changeset a493682 for src/libcfa/stdlib.c
- Timestamp:
- Jul 17, 2017, 1:55:22 PM (7 years ago)
- 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:
- b46e3bd
- Parents:
- bf30ab3
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/libcfa/stdlib.c
rbf30ab3 ra493682 41 41 forall( dtype T | sized(T), ttype Params | { void ?{}( T &, Params ); } ) 42 42 T * new( Params p ) { 43 return (malloc()){ p }; // run constructor43 return &(*malloc()){ p }; // run constructor 44 44 } // new 45 45 … … 67 67 T *arr = alloc( dim ); 68 68 for ( unsigned int i = 0; i < dim; i += 1 ) { 69 ( &arr[i]){ p }; // run constructor69 (arr[i]){ p }; // run constructor 70 70 } // for 71 71 return arr; … … 76 76 if ( arr ) { // ignore null 77 77 for ( int i = dim - 1; i >= 0; i -= 1 ) { // reverse allocation order, must be unsigned 78 ^( &arr[i]){}; // run destructor78 ^(arr[i]){}; // run destructor 79 79 } // for 80 80 free( arr ); … … 86 86 if ( arr ) { // ignore null 87 87 for ( int i = dim - 1; i >= 0; i -= 1 ) { // reverse allocation order, must be unsigned 88 ^( &arr[i]){}; // run destructor88 ^(arr[i]){}; // run destructor 89 89 } // for 90 90 free( arr );
Note: See TracChangeset
for help on using the changeset viewer.