Changeset a4683611


Ignore:
Timestamp:
Jun 2, 2017, 5:01:19 PM (5 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
aaron-thesis, arm-eh, cleanup-dtors, deferred_resn, demangler, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, resolv-new, with_gc
Children:
2c6c893
Parents:
421a287
Message:

third attempt at memory-allocation routines

Location:
src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/libcfa/stdlib

    r421a287 ra4683611  
    1010// Created On       : Thu Jan 28 17:12:35 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Jun  1 22:46:43 2017
    13 // Update Count     : 216
     12// Last Modified On : Fri Jun  2 15:51:03 2017
     13// Update Count     : 218
    1414//
    1515
     
    127127static inline forall( dtype T | sized(T) ) T * memset( T dest[], size_t dim, char c ) {
    128128        //printf( "X19\n" );
    129         return memset( dest, c, dim * sizeof(T) );
     129        return (void *)memset( dest, c, dim * sizeof(T) );      // C memset
    130130} // memset
    131131static inline forall( dtype T | sized(T) ) T * memcpy( T dest[], const T src[], size_t dim ) {
  • src/tests/.expect/alloc.txt

    r421a287 ra4683611  
    13130x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101
    1414
    15 C   realloc 40
     15C   realloc
    16160xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef
    17 CFA realloc 88
     17CFA realloc
    18180xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101
    1919
    20 CFA resize alloc 40
     20CFA resize alloc
    21210xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef
    22 CFA resize array alloc 88
     22CFA resize array alloc
    23230xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101
    24 CFA resize array alloc 40
     24CFA resize array alloc
    25250xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef
    26 CFA resize array alloc 40, fill
     26CFA resize array alloc, fill
    27270x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101
    28 CFA resize array alloc 88, fill
     28CFA resize array alloc, fill
    29290x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101
    30 CFA resize array alloc 40, fill
     30CFA resize array alloc, fill
    31310x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101
    3232
  • src/tests/alloc.c

    r421a287 ra4683611  
    1010// Created On       : Wed Feb  3 07:56:22 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Jun  1 21:33:49 2017
    13 // Update Count     : 315
     12// Last Modified On : Fri Jun  2 15:13:03 2017
     13// Update Count     : 316
    1414//
    1515
     
    8787    p = (void *)realloc( p, dim * sizeof(*p) );                 // C realloc
    8888        for ( int i = 0; i < dim; i += 1 ) { p[i] = 0xdeadbeef; }
    89         printf( "C   realloc %ld\n", malloc_usable_size( p ) );
     89        printf( "C   realloc\n" );
    9090        for ( int i = 0; i < dim; i += 1 ) { printf( "%#x ", p[i] ); }
    9191        printf( "\n" );
     
    9393    p = realloc( p, 2 * dim * sizeof(*p) );                             // CFA realloc
    9494        for ( int i = dim; i < 2 * dim; i += 1 ) { p[i] = 0x1010101; }
    95         printf( "CFA realloc %ld\n", malloc_usable_size( p ) );
     95        printf( "CFA realloc\n" );
    9696        for ( int i = 0; i < 2 * dim; i += 1 ) { printf( "%#x ", p[i] ); }
    9797        printf( "\n" );
     
    104104    p = alloc( p, dim );                                                                // CFA resize array alloc
    105105        for ( int i = 0; i < dim; i += 1 ) { p[i] = 0xdeadbeef; }
    106         printf( "CFA resize alloc %ld\n", malloc_usable_size( p ) );
     106        printf( "CFA resize alloc\n" );
    107107        for ( int i = 0; i < dim; i += 1 ) { printf( "%#x ", p[i] ); }
    108108        printf( "\n" );
     
    110110    p = alloc( p, 2 * dim );                                                    // CFA resize array alloc
    111111        for ( int i = dim; i < 2 * dim; i += 1 ) { p[i] = 0x1010101; }
    112         printf( "CFA resize array alloc %ld\n", malloc_usable_size( p ) );
     112        printf( "CFA resize array alloc\n" );
    113113        for ( int i = 0; i < 2 * dim; i += 1 ) { printf( "%#x ", p[i] ); }
    114114        printf( "\n" );
    115115
    116116    p = alloc( p, dim );                                                                // CFA array alloc
    117         printf( "CFA resize array alloc %ld\n", malloc_usable_size( p ) );
     117        printf( "CFA resize array alloc\n" );
    118118        for ( int i = 0; i < dim; i += 1 ) { printf( "%#x ", p[i] ); }
    119119        printf( "\n" );
     
    123123
    124124    p = alloc( p, dim, fill );                                                  // CFA array alloc, fill
    125         printf( "CFA resize array alloc %ld, fill\n", malloc_usable_size( p ) );
     125        printf( "CFA resize array alloc, fill\n" );
    126126        for ( int i = 0; i < dim; i += 1 ) { printf( "%#x ", p[i] ); }
    127127        printf( "\n" );
    128128
    129129    p = alloc( p, 2 * dim, fill );                                              // CFA array alloc, fill
    130         printf( "CFA resize array alloc %ld, fill\n", malloc_usable_size( p ) );
     130        printf( "CFA resize array alloc, fill\n" );
    131131        for ( int i = 0; i < 2 * dim; i += 1 ) { printf( "%#x ", p[i] ); }
    132132        printf( "\n" );
    133133
    134134    p = alloc( p, dim, fill );                                                  // CFA array alloc, fill
    135         printf( "CFA resize array alloc %ld, fill\n", malloc_usable_size( p ) );
     135        printf( "CFA resize array alloc, fill\n" );
    136136        for ( int i = 0; i < dim; i += 1 ) { printf( "%#x ", p[i] );; }
    137137        printf( "\n" );
Note: See TracChangeset for help on using the changeset viewer.