Changeset e672372 for src/tests/alloc.c


Ignore:
Timestamp:
Dec 25, 2017, 11:43:00 AM (7 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, 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
Message:

more inline code in stdlib and update tests

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/tests/alloc.c

    r1e6e08de re672372  
    1010// Created On       : Wed Feb  3 07:56:22 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Jul 20 16:01:10 2017
    13 // Update Count     : 318
     12// Last Modified On : Fri Nov 24 23:06:42 2017
     13// Update Count     : 319
    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         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
    3540        *p = 0xdeadbeef;
    3641        printf( "C   malloc %#x\n", *p );
     
    5459        printf( "\n" );
    5560
    56         p = (int *)calloc( dim, sizeof( *p ) );                    // C array calloc, type unsafe
     61        p = (int *)calloc( dim, sizeof( *p ) );                         // C array calloc, type unsafe
    5762        printf( "C   array calloc, fill 0\n" );
    5863        for ( int i = 0; i < dim; i += 1 ) { printf( "%#x ", p[i] ); }
     
    8388        printf( "\n" );
    8489
    85         p = (int *)(void *)realloc( p, dim * sizeof(*p) );         // C realloc
     90        p = (int *)(void *)realloc( p, dim * sizeof(*p) );      // C realloc
    8691        for ( int i = 0; i < dim; i += 1 ) { p[i] = 0xdeadbeef; }
    8792        printf( "C   realloc\n" );
Note: See TracChangeset for help on using the changeset viewer.