Ignore:
Timestamp:
Jul 17, 2017, 1:55:22 PM (7 years ago)
Author:
Rob Schluntz <rschlunt@…>
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
Message:

Update several library files to use references

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/libcfa/stdlib.c

    rbf30ab3 ra493682  
    4141forall( dtype T | sized(T), ttype Params | { void ?{}( T &, Params ); } )
    4242T * new( Params p ) {
    43         return (malloc()){ p };                                                         // run constructor
     43        return &(*malloc()){ p };                                                               // run constructor
    4444} // new
    4545
     
    6767        T *arr = alloc( dim );
    6868        for ( unsigned int i = 0; i < dim; i += 1 ) {
    69                 (&arr[i]){ p };                                                                 // run constructor
     69                (arr[i]){ p };                                                                  // run constructor
    7070        } // for
    7171        return arr;
     
    7676        if ( arr ) {                                                                            // ignore null
    7777                for ( int i = dim - 1; i >= 0; i -= 1 ) {               // reverse allocation order, must be unsigned
    78                         ^(&arr[i]){};                                                           // run destructor
     78                        ^(arr[i]){};                                                            // run destructor
    7979                } // for
    8080                free( arr );
     
    8686        if ( arr ) {                                                                            // ignore null
    8787                for ( int i = dim - 1; i >= 0; i -= 1 ) {               // reverse allocation order, must be unsigned
    88                         ^(&arr[i]){};                                                           // run destructor
     88                        ^(arr[i]){};                                                            // run destructor
    8989                } // for
    9090                free( arr );
Note: See TracChangeset for help on using the changeset viewer.