Ignore:
Timestamp:
Jan 8, 2015, 2:37:47 PM (8 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
aaron-thesis, arm-eh, 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, resolv-new, string, with_gc
Children:
6c3744e
Parents:
17cd4eb
Message:

fix uninitialized value, fix memory reads after frees

File:
1 edited

Legend:

Unmodified
Added
Removed
  • translator/examples/swap.c

    r17cd4eb r0b8cd72  
    44
    55forall( type T )
    6 T swap( T *left, T *right ) {
     6void swap( T *left, T *right ) {
    77    T temp;
    88    temp = *left;
    99    *left = *right;
    1010    *right = temp;
    11     return *right;
    1211}
    1312
     
    1514    int x = 1, y = 2;
    1615    printf( "%d %d\n", x, y );
    17     int w;
    18     w = swap( &x, &y );
    19     printf( "%d %d %d\n", w, x, y );
     16    swap( &x, &y );
     17    printf( "%d %d\n", x, y );
    2018}
    2119
Note: See TracChangeset for help on using the changeset viewer.