Ignore:
Timestamp:
Jan 29, 2016, 4:36:39 PM (9 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, string, with_gc
Children:
ae8b942
Parents:
f3fc8cbe
Message:

building runtime library (first attempt)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/examples/alloc.c

    rf3fc8cbe rd3b7937  
     1#if 0
    12extern "C" {
    23    typedef long unsigned int size_t;
     
    1516    return (T *)calloc( size, sizeof(T) );
    1617}
     18#endif
     19typedef int size_t;
    1720forall( type T ) T * realloc( T *ptr, size_t n ) {
    18     return (T *)(void *)realloc( ptr, sizeof(T) );
     21//    return (T *)(void *)realloc( ptr, sizeof(T) );
    1922}
    20 forall( type T ) T * realloc( T *ptr, size_t n, T c ) {
    21     return (T *)realloc( ptr, n );
    22 }
     23//forall( type T ) T * realloc( T *ptr, size_t n, T c ) {
     24//    return (T *)realloc( ptr, n );
     25//}
    2326
    24 int *foo( int *p, int c );
    25 int *bar( int *p, int c );
    26 int *baz( int *p, int c );
     27//int *foo( int *p, int c );
     28//int *bar( int *p, int c );
     29//int *baz( int *p, int c );
    2730
    2831int main( void ) {
    29     size_t size = 10;
    30     int * x = malloc();
    31     x = malloc();
    32     x = calloc( 10 );                                   // calloc: array set to 0
    33     x = realloc( x, 10 );
    34     x = realloc( x, 10, '\0' );
    35     x = malloc( 5 );
    36     float *fp = malloc() + 1;
     32    // size_t size = 10;
     33    //int * x = malloc();
     34    int * x;
     35    // x = malloc();
     36    // x = calloc( 10 );                                        // calloc: array set to 0
     37    // x = realloc( x, 10 );
     38    // x = realloc( x, 10, '\0' );
     39    // x = malloc( 5 );
     40    // float *fp = malloc() + 1;
    3741
    3842    struct St1 { int x; double y; };
    3943    struct St1 * st1;
    40     double *y;
     44//    double *y;
    4145    x = realloc( st1, 10 );                             // SHOULD FAIL!!
    4246#if 0
Note: See TracChangeset for help on using the changeset viewer.