Ignore:
Timestamp:
Jan 30, 2017, 12:29:29 PM (7 years ago)
Author:
Thierry Delisle <tdelisle@…>
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:
1e6e231a
Parents:
f97b614
Message:

new, delete, malloc, etc. no longer require an otype, only a sized dtype

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/libcfa/stdlib.c

    rf97b614 r59239b8  
    2727} // extern "C"
    2828
    29 forall( otype T ) T * malloc( void ) {
     29forall( dtype T | sized(T) ) T * malloc( void ) {
    3030        //printf( "malloc1\n" );
    3131    return (T *)malloc( sizeof(T) );
    3232} // malloc
    33 forall( otype T ) T * malloc( char fill ) {
     33forall( dtype T | sized(T) ) T * malloc( char fill ) {
    3434        //printf( "malloc3\n" );
    3535        T * ptr = (T *)malloc( sizeof(T) );
     
    3737} // malloc
    3838
    39 forall( otype T ) T * calloc( size_t nmemb ) {
     39forall( dtype T | sized(T) ) T * calloc( size_t nmemb ) {
    4040        //printf( "calloc\n" );
    4141    return (T *)calloc( nmemb, sizeof(T) );
    4242} // calloc
    4343
    44 forall( otype T ) T * realloc( T * ptr, size_t size ) {
     44forall( dtype T | sized(T) ) T * realloc( T * ptr, size_t size ) {
    4545        //printf( "realloc1\n" );
    4646    return (T *)(void *)realloc( (void *)ptr, size );
    4747} // realloc
    48 forall( otype T ) T * realloc( T * ptr, size_t size, unsigned char fill ) {
     48forall( dtype T | sized(T) ) T * realloc( T * ptr, size_t size, unsigned char fill ) {
    4949        //printf( "realloc2\n" );
    5050    char * nptr = (T *)(void *)realloc( (void *)ptr, size );
     
    5454} // realloc
    5555
    56 forall( otype T ) T * malloc( T * ptr, size_t size ) {
     56forall( dtype T | sized(T) ) T * malloc( T * ptr, size_t size ) {
    5757        //printf( "malloc4\n" );
    5858    return (T *)realloc( ptr, size );
    5959} // malloc
    60 forall( otype T ) T * malloc( T * ptr, size_t size, unsigned char fill ) {
     60forall( dtype T | sized(T) ) T * malloc( T * ptr, size_t size, unsigned char fill ) {
    6161        //printf( "malloc5\n" );
    6262    return (T *)realloc( ptr, size, fill );
    6363} // malloc
    6464
    65 forall( otype T ) T * aligned_alloc( size_t alignment ) {
     65forall( dtype T | sized(T) ) T * aligned_alloc( size_t alignment ) {
    6666        //printf( "aligned_alloc\n" );
    6767    return (T *)memalign( alignment, sizeof(T) );
    6868} // aligned_alloc
    6969
    70 forall( otype T ) T * memalign( size_t alignment ) {
     70forall( dtype T | sized(T) ) T * memalign( size_t alignment ) {
    7171        //printf( "memalign\n" );
    7272    return (T *)memalign( alignment, sizeof(T) );
    7373} // memalign
    7474
    75 forall( otype T ) int posix_memalign( T ** ptr, size_t alignment ) {
     75forall( dtype T | sized(T) ) int posix_memalign( T ** ptr, size_t alignment ) {
    7676        //printf( "posix_memalign\n" );
    7777    return posix_memalign( (void **)ptr, alignment, sizeof(T) );
    7878} // posix_memalign
    7979
    80 forall( otype T, ttype Params | { void ?{}(T *, Params); } )
     80forall( dtype T, ttype Params | sized(T) | { void ?{}(T *, Params); } )
    8181T * new( Params p ) {
    8282        return ((T*)malloc()){ p };
Note: See TracChangeset for help on using the changeset viewer.