Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/tests/alloc.c

    re672372 rcdbfab0  
    1010// Created On       : Wed Feb  3 07:56:22 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Nov 24 23:06:42 2017
    13 // Update Count     : 319
     12// Last Modified On : Thu Jul 20 16:01:10 2017
     13// Update Count     : 318
    1414//
    1515
     
    1919#include <stdlib.h>                                                                             // posix_memalign
    2020#include <fstream>
    21 #include <stdlib>                                                                               // access C malloc, realloc
     21#include <stdlib>                                                                                       // access C malloc, realloc
    2222
    2323int * foo( int * p, int c ) { return p; }
     
    3232        // allocation, non-array types
    3333
    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
    4035        *p = 0xdeadbeef;
    4136        printf( "C   malloc %#x\n", *p );
     
    5954        printf( "\n" );
    6055
    61         p = (int *)calloc( dim, sizeof( *p ) );                         // C array calloc, type unsafe
     56        p = (int *)calloc( dim, sizeof( *p ) );                    // C array calloc, type unsafe
    6257        printf( "C   array calloc, fill 0\n" );
    6358        for ( int i = 0; i < dim; i += 1 ) { printf( "%#x ", p[i] ); }
     
    8883        printf( "\n" );
    8984
    90         p = (int *)(void *)realloc( p, dim * sizeof(*p) );      // C realloc
     85        p = (int *)(void *)realloc( p, dim * sizeof(*p) );         // C realloc
    9186        for ( int i = 0; i < dim; i += 1 ) { p[i] = 0xdeadbeef; }
    9287        printf( "C   realloc\n" );
Note: See TracChangeset for help on using the changeset viewer.