ADT
aaron-thesis
arm-eh
ast-experimental
cleanup-dtors
ctor
deferred_resn
demangler
enum
forall-pointer-decay
gc_noraii
jacob/cs343-translation
jenkins-sandbox
memory
new-ast
new-ast-unique-expr
new-env
no_list
persistent-indexer
pthread-emulation
qualifiedEnum
resolv-new
string
with_gc
|
Last change
on this file since fe3b61b was 0b8cd722, checked in by Peter A. Buhr <pabuhr@…>, 11 years ago |
|
fix uninitialized value, fix memory reads after frees
|
-
Property mode
set to
100644
|
|
File size:
375 bytes
|
| Line | |
|---|
| 1 | extern "C" {
|
|---|
| 2 | int printf( const char *, ... );
|
|---|
| 3 | }
|
|---|
| 4 |
|
|---|
| 5 | forall( type T )
|
|---|
| 6 | void swap( T *left, T *right ) {
|
|---|
| 7 | T temp;
|
|---|
| 8 | temp = *left;
|
|---|
| 9 | *left = *right;
|
|---|
| 10 | *right = temp;
|
|---|
| 11 | }
|
|---|
| 12 |
|
|---|
| 13 | int main() {
|
|---|
| 14 | int x = 1, y = 2;
|
|---|
| 15 | printf( "%d %d\n", x, y );
|
|---|
| 16 | swap( &x, &y );
|
|---|
| 17 | printf( "%d %d\n", x, y );
|
|---|
| 18 | }
|
|---|
| 19 |
|
|---|
| 20 | // Local Variables: //
|
|---|
| 21 | // compile-command: "../../bin/cfa swap.c" //
|
|---|
| 22 | // End: //
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.