Changeset 627f585 for src/libcfa


Ignore:
Timestamp:
Jan 10, 2017, 2:32:33 PM (8 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:
dd0c97b
Parents:
f831177
Message:

moved new and delete to stdlib

Location:
src/libcfa
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/libcfa/stdlib

    rf831177 r627f585  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // stdlib -- 
     7// stdlib --
    88//
    99// Author           : Peter A. Buhr
     
    4444void free( void * ptr );
    4545} // extern "C"
     46
     47forall( otype T, ttype Params | { void ?{}(T *, Params); } ) T * new( Params p );
     48forall( dtype T | { void ^?{}(T *); } ) void delete( T * ptr );
     49
    4650
    4751//---------------------------------------
  • src/libcfa/stdlib.c

    rf831177 r627f585  
    7878} // posix_memalign
    7979
     80forall( otype T, ttype Params | { void ?{}(T *, Params); } )
     81T * new( Params p ) {
     82        return ((T*)malloc()){ p };
     83}
     84
     85forall( dtype T | { void ^?{}(T *); } )
     86void delete( T * ptr ) {
     87  if ( ptr ) {
     88    ^ptr{};
     89    free( ptr );
     90  }
     91}
     92
    8093//---------------------------------------
    8194
Note: See TracChangeset for help on using the changeset viewer.