Changeset e672372 for src/tests/alloc.c
- Timestamp:
- Dec 25, 2017, 11:43:00 AM (5 years ago)
- Branches:
- aaron-thesis, arm-eh, 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:
- 9c47a47, d9ff69a
- Parents:
- 1e6e08de
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/tests/alloc.c
r1e6e08de re672372 10 10 // Created On : Wed Feb 3 07:56:22 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Jul 20 16:01:10201713 // Update Count : 31 812 // Last Modified On : Fri Nov 24 23:06:42 2017 13 // Update Count : 319 14 14 // 15 15 … … 19 19 #include <stdlib.h> // posix_memalign 20 20 #include <fstream> 21 #include <stdlib> 21 #include <stdlib> // access C malloc, realloc 22 22 23 23 int * foo( int * p, int c ) { return p; } … … 32 32 // allocation, non-array types 33 33 34 p = (int *)(void *)malloc( sizeof(*p) ); // C malloc, type unsafe 34 // int &r = malloc(); 35 // r = 0xdeadbeef; 36 // printf( "C malloc %#x\n", r ); 37 // free( &r ); 38 39 p = (int *)(void *)malloc( sizeof(*p) ); // C malloc, type unsafe 35 40 *p = 0xdeadbeef; 36 41 printf( "C malloc %#x\n", *p ); … … 54 59 printf( "\n" ); 55 60 56 p = (int *)calloc( dim, sizeof( *p ) ); 61 p = (int *)calloc( dim, sizeof( *p ) ); // C array calloc, type unsafe 57 62 printf( "C array calloc, fill 0\n" ); 58 63 for ( int i = 0; i < dim; i += 1 ) { printf( "%#x ", p[i] ); } … … 83 88 printf( "\n" ); 84 89 85 p = (int *)(void *)realloc( p, dim * sizeof(*p) ); 90 p = (int *)(void *)realloc( p, dim * sizeof(*p) ); // C realloc 86 91 for ( int i = 0; i < dim; i += 1 ) { p[i] = 0xdeadbeef; } 87 92 printf( "C realloc\n" );
Note: See TracChangeset
for help on using the changeset viewer.