Changeset b6838214 for src/tests/alloc.c


Ignore:
Timestamp:
Jan 23, 2018, 5:46:43 PM (8 years ago)
Author:
Alan Kennedy <afakenne@…>
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:
258e6ad5
Parents:
b158d8f (diff), 15d248e (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

add context switch for ARM

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/tests/alloc.c

    rb158d8f rb6838214  
    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 : Mon Jan 22 21:26:40 2018
     13// Update Count     : 326
    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 *)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 *)realloc( p, dim * sizeof(*p) );                      // C realloc
    8691        for ( int i = 0; i < dim; i += 1 ) { p[i] = 0xdeadbeef; }
    8792        printf( "C   realloc\n" );
     
    254259        free( p );
    255260
     261#ifdef ERR1
    256262        stp = malloc();
    257263        printf( "\nSHOULD FAIL\n" );
    258 #ifdef ERR1
    259         p = alloc( stp, dim * sizeof(*stp) );
     264        p = realloc( stp, dim * sizeof( *stp ) );
     265        p = alloc( stp, dim * sizeof( *stp ) );
    260266        p = memset( stp, 10 );
    261267        p = memcpy( &st1, &st );
Note: See TracChangeset for help on using the changeset viewer.