Changes in src/tests/alloc.c [e672372:cdbfab0]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/tests/alloc.c
re672372 rcdbfab0 10 10 // Created On : Wed Feb 3 07:56:22 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Nov 24 23:06:42201713 // Update Count : 31 912 // Last Modified On : Thu Jul 20 16:01:10 2017 13 // Update Count : 318 14 14 // 15 15 … … 19 19 #include <stdlib.h> // posix_memalign 20 20 #include <fstream> 21 #include <stdlib> // access C malloc, realloc21 #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 // 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 34 p = (int *)(void *)malloc( sizeof(*p) ); // C malloc, type unsafe 40 35 *p = 0xdeadbeef; 41 36 printf( "C malloc %#x\n", *p ); … … 59 54 printf( "\n" ); 60 55 61 p = (int *)calloc( dim, sizeof( *p ) ); 56 p = (int *)calloc( dim, sizeof( *p ) ); // C array calloc, type unsafe 62 57 printf( "C array calloc, fill 0\n" ); 63 58 for ( int i = 0; i < dim; i += 1 ) { printf( "%#x ", p[i] ); } … … 88 83 printf( "\n" ); 89 84 90 p = (int *)(void *)realloc( p, dim * sizeof(*p) ); 85 p = (int *)(void *)realloc( p, dim * sizeof(*p) ); // C realloc 91 86 for ( int i = 0; i < dim; i += 1 ) { p[i] = 0xdeadbeef; } 92 87 printf( "C realloc\n" );
Note:
See TracChangeset
for help on using the changeset viewer.