Changeset 1988572


Ignore:
Timestamp:
Jul 24, 2022, 5:49:53 PM (21 months ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, ast-experimental, master, pthread-emulation, qualifiedEnum
Children:
24a3d2b, 6a6544d
Parents:
e01d2f6
Message:

formatting, removed unnecessary casts

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tests/alloc2.cfa

    re01d2f6 r1988572  
    1111typedef struct S1 T1;
    1212
    13 void test_base( void * ip, size_t size, size_t align) {
     13void test_base( void * ip, size_t size, size_t align ) {
    1414        tests_total += 1;
    15 //      printf("DEBUG: starting test %d\n", tests_total);
    16         bool passed = (malloc_size(ip) == size) && (malloc_usable_size(ip) >= size) && (malloc_alignment(ip) == align) && ((uintptr_t)ip % align  == 0);
    17         if (!passed) {
    18                 printf("failed test %3d: %4zu %4zu but got %4zu ( %3zu ) %4zu\n", tests_total, size, align, malloc_size(ip), malloc_usable_size(ip), malloc_alignment(ip));
     15//      printf( "DEBUG: starting test %d\n", tests_total);
     16        bool passed = (malloc_size( ip ) == size) && (malloc_usable_size( ip ) >= size) && (malloc_alignment( ip ) == align) && ((uintptr_t)ip % align  == 0);
     17        if ( ! passed ) {
     18                printf( "failed test %3d: %4zu %4zu but got %4zu ( %3zu ) %4zu\n", tests_total, size, align, malloc_size( ip ), malloc_usable_size( ip ), malloc_alignment( ip ) );
    1919                tests_failed += 1;
    20         }
    21 //      printf("DEBUG: done test %d\n", tests_total);
     20        } // if
     21//      printf( "DEBUG: done test %d\n", tests_total);
    2222}
    2323
    24 void test_fill( void * ip_, size_t start, size_t end, char fill) {
     24void test_fill( void * ip_, size_t start, size_t end, char fill ) {
    2525        tests_total += 1;
    26 //      printf("DEBUG: starting test %d\n", tests_total);
     26//      printf( "DEBUG: starting test %d\n", tests_total );
    2727        bool passed = true;
    2828        char * ip = (char *) ip_;
    29         for (i; start ~ end) passed = passed && (ip[i] == fill);
    30         if (!passed) {
    31                 printf("failed test %3d: fill C\n", tests_total);
     29        for ( i; start ~ end ) passed = passed && (ip[i] == fill);
     30        if ( ! passed ) {
     31                printf( "failed test %3d: fill C\n", tests_total );
    3232                tests_failed += 1;
    33         }
    34 //      printf("DEBUG: done test %d\n", tests_total);
     33        } // if
     34//      printf( "DEBUG: done test %d\n", tests_total );
    3535}
    3636
    37 void test_fill( void * ip_, size_t start, size_t end, int fill) {
     37void test_fill( void * ip_, size_t start, size_t end, int fill ) {
    3838        tests_total += 1;
    39 //      printf("DEBUG: starting test %d\n", tests_total);
     39//      printf( "DEBUG: starting test %d\n", tests_total );
    4040        bool passed = true;
    41         int * ip = (int *) ip_;
    42         for (i; start ~ end) passed = passed && (ip[i] == fill);
    43         if (!passed) {
    44                 printf("failed test %3d: fill int\n", tests_total);
     41        int * ip = (int *)ip_;
     42        for (i; start ~ end ) passed = passed && (ip[i] == fill);
     43        if ( ! passed ) {
     44                printf( "failed test %3d: fill int\n", tests_total );
    4545                tests_failed += 1;
    46         }
    47 //      printf("DEBUG: done test %d\n", tests_total);
     46        } // if
     47//      printf( "DEBUG: done test %d\n", tests_total );
    4848}
    4949
    50 void test_fill( void * ip_, size_t start, size_t end, int * fill) {
     50void test_fill( void * ip_, size_t start, size_t end, int * fill ) {
    5151        tests_total += 1;
    52 //      printf("DEBUG: starting test %d\n", tests_total);
    53         bool passed = (memcmp((void*)((uintptr_t)ip_ + start), (void*)fill, end) == 0);
    54         if (!passed) {
    55                 printf("failed test %3d: fill int A\n", tests_total);
     52//      printf( "DEBUG: starting test %d\n", tests_total );
     53        bool passed = memcmp((void*)((uintptr_t )ip_ + start ), (void*)fill, end ) == 0;
     54        if ( ! passed ) {
     55                printf( "failed test %3d: fill int A\n", tests_total );
    5656                tests_failed += 1;
    57         }
    58 //      printf("DEBUG: done test %d\n", tests_total);
     57        } // if
     58//      printf( "DEBUG: done test %d\n", tests_total );
    5959}
    6060
    61 void test_fill( void * ip_, size_t start, size_t end, T1 fill) {
     61void test_fill( void * ip_, size_t start, size_t end, T1 fill ) {
    6262        tests_total += 1;
    63 //      printf("DEBUG: starting test %d\n", tests_total);
     63//      printf( "DEBUG: starting test %d\n", tests_total );
    6464        bool passed = true;
    6565        T1 * ip = (T1 *) ip_;
    66         for (i; start ~ end) passed = passed && (ip[i].data == fill.data);
    67         if (!passed) {
    68                 printf("failed test %3d: fill T1\n", tests_total);
     66        for ( i; start ~ end ) passed = passed && (ip[i].data == fill.data );
     67        if ( ! passed ) {
     68                printf( "failed test %3d: fill T1\n", tests_total );
    6969                tests_failed += 1;
    70         }
    71 //      printf("DEBUG: done test %d\n", tests_total);
     70        } // if
     71//      printf( "DEBUG: done test %d\n", tests_total );
    7272}
    7373
    74 void test_fill( void * ip_, size_t start, size_t end, T1 * fill) {
     74void test_fill( void * ip_, size_t start, size_t end, T1 * fill ) {
    7575        tests_total += 1;
    76 //      printf("DEBUG: starting test %d\n", tests_total);
    77         bool passed = (memcmp((void*)((uintptr_t)ip_ + start), (void*)fill, end) == 0);
    78         if (!passed) {
    79                 printf("failed test %3d: fill T1 A\n", tests_total);
     76//      printf( "DEBUG: starting test %d\n", tests_total );
     77        bool passed = memcmp( (void*)((uintptr_t )ip_ + start ), (void*)fill, end ) == 0;
     78        if ( ! passed ) {
     79                printf( "failed test %3d: fill T1 A\n", tests_total );
    8080                tests_failed += 1;
    81         }
    82 //      printf("DEBUG: done test %d\n", tests_total);
     81        } // if
     82//      printf( "DEBUG: done test %d\n", tests_total );
    8383}
    8484
    85 void test_use( int * ip, size_t dim) {
     85void test_use( int * ip, size_t dim ) {
    8686        tests_total += 1;
    87 //      printf("DEBUG: starting test %d\n", tests_total);
     87//      printf( "DEBUG: starting test %d\n", tests_total );
    8888        bool passed = true;
    89         for (i; 0 ~ dim) ip[i] = 0xdeadbeef;
    90         for (i; 0 ~ dim) passed = passed &&  (ip[i] == 0xdeadbeef);
    91         if (!passed) {
    92                 printf("failed test %3d: use int\n", tests_total);
     89        for ( i; 0 ~ dim ) ip[i] = 0xdeadbeef;
     90        for ( i; 0 ~ dim ) passed = passed &&  (ip[i] == 0xdeadbeef);
     91        if ( ! passed ) {
     92                printf( "failed test %3d: use int\n", tests_total );
    9393                tests_failed += 1;
    94         }
    95 //      printf("DEBUG: done test %d\n", tests_total);
     94        } // if
     95//      printf( "DEBUG: done test %d\n", tests_total );
    9696}
    9797
    98 void test_use( T1 * ip, size_t dim) {
     98void test_use( T1 * ip, size_t dim ) {
    9999        tests_total += 1;
    100 //      printf("DEBUG: starting test %d\n", tests_total);
     100//      printf( "DEBUG: starting test %d\n", tests_total );
    101101        bool passed = true;
    102         for (i; 0 ~ dim) ip[i].data = 0xdeadbeef;
    103         for (i; 0 ~ dim) passed = passed &&  (ip[i].data == 0xdeadbeef);
    104         if (!passed) {
    105                 printf("failed test %3d: use T1\n", tests_total);
     102        for ( i; 0 ~ dim ) ip[i].data = 0xdeadbeef;
     103        for ( i; 0 ~ dim ) passed = passed &&  (ip[i].data == 0xdeadbeef);
     104        if ( ! passed ) {
     105                printf( "failed test %3d: use T1\n", tests_total );
    106106                tests_failed += 1;
    107         }
    108 //      printf("DEBUG: done test %d\n", tests_total);
     107        } // if
     108//      printf( "DEBUG: done test %d\n", tests_total );
    109109}
    110110
    111111int main( void ) {
     112        enum { dim = 8, align = 64, libAlign = libAlign() };
    112113        size_t elemSize = sizeof(int);
    113         size_t dim = 8;
    114114        size_t size = dim * elemSize;
    115         size_t align = 64;
    116         const size_t libAlign = libAlign();
    117 
    118         int     FillT = 9;
    119         char    FillC = 'a';
    120         int   * FillA = calloc(dim / 4);
    121         T1          FillT1 = { FillT };
    122         T1        * FillT1A = (T1 *)(void *) malloc( (dim / 4) * sizeof(T1) );
    123         for (i; 0 ~ (dim / 4) ) FillT1A[i] = FillT1;
    124 
    125         int             * ip;
    126         int     * op;
    127         double  * dp;
    128         T1      * t1p;
    129         T1          * t1op;
     115
     116        int FillT = 9;
     117        char FillC = 'a';
     118        int * FillA = calloc( dim / 4 );
     119        T1 FillT1 = { FillT };
     120        T1 * FillT1A = (T1 *)(void *) malloc( (dim / 4) * sizeof(T1) );
     121        for ( i; 0 ~ (dim / 4) ) FillT1A[i] = FillT1;
     122
     123        int * ip;
     124        int * op;
     125        double * dp;
     126        T1 * t1p;
     127        T1 * t1op;
    130128
    131129        // testing alloc
     
    136134
    137135        ip = alloc();
    138         test_base(ip, elemSize, libAlign);
    139         test_use(ip, elemSize / elemSize);
    140         free(ip);
     136        test_base( ip, elemSize, libAlign );
     137        test_use( ip, elemSize / elemSize );
     138        free( ip );
    141139
    142140        ip = alloc( dim );
    143         test_base(ip, size, libAlign);
    144         test_use(ip, size / elemSize);
    145         free(ip);
     141        test_base( ip, size, libAlign );
     142        test_use( ip, size / elemSize );
     143        free( ip );
    146144
    147145        ip = alloc( 0 );
    148         test_base(ip, 0, libAlign);
    149         free(ip);
     146        test_base( ip, 0, libAlign );
     147        free( ip );
    150148
    151149        dp = alloc( dim );
    152150        ip = alloc( dp`resize );
    153         test_base(ip, elemSize, libAlign);
    154         test_use(ip, elemSize / elemSize);
    155         free(ip);
    156 
    157         ip = alloc( ((double*)0p)`resize );
    158         test_base(ip, elemSize, libAlign);
    159         test_use(ip, elemSize / elemSize);
    160         free(ip);
     151        test_base( ip, elemSize, libAlign );
     152        test_use( ip, elemSize / elemSize );
     153        free( ip );
     154
     155        ip = alloc( ((double *)0p)`resize );
     156        test_base( ip, elemSize, libAlign );
     157        test_use( ip, elemSize / elemSize );
     158        free( ip );
    161159
    162160        dp = alloc( dim );
    163161        ip = alloc( dim, dp`resize );
    164         test_base(ip, size, libAlign);
    165         test_use(ip, size / elemSize);
    166         free(ip);
     162        test_base( ip, size, libAlign );
     163        test_use( ip, size / elemSize );
     164        free( ip );
    167165
    168166        dp = alloc( dim );
    169167        ip = alloc( 0, dp`resize );
    170         test_base(ip, 0, libAlign);
    171         free(ip);
    172 
    173         ip = alloc( dim, ((double*)0p)`resize );
    174         test_base(ip, size, libAlign);
    175         test_use(ip, size / elemSize);
    176         free(ip);
    177 
    178         ip = alloc( 0, ((double*)0p)`resize );
    179         test_base(ip, 0, libAlign);
    180         free(ip);
    181 
    182         op = alloc( dim, ((int)0xdeadbeef)`fill );
     168        test_base( ip, 0, libAlign );
     169        free( ip );
     170
     171        ip = alloc( dim, 0p`resize );
     172        test_base( ip, size, libAlign );
     173        test_use( ip, size / elemSize );
     174        free( ip );
     175
     176        ip = alloc( 0, 0p`resize );
     177        test_base( ip, 0, libAlign );
     178        free( ip );
     179
     180        op = alloc( dim, 0xdeadbeefN`fill );
    183181        ip = alloc( dim, op`realloc );
    184         test_base(ip, size, libAlign);
    185         test_fill(ip, 0, dim, (int)0xdeadbeef);
    186         test_use(ip, size / elemSize);
    187         free(ip);
    188 
    189         op = alloc( dim, ((int)0xdeadbeef)`fill );
     182        test_base( ip, size, libAlign );
     183        test_fill( ip, 0, dim, 0xdeadbeefN );
     184        test_use( ip, size / elemSize );
     185        free( ip );
     186
     187        op = alloc( dim, 0xdeadbeefN`fill );
    190188        ip = alloc( 0, op`realloc );
    191         test_base(ip, 0, libAlign);
    192         free(ip);
    193 
    194         ip = alloc( dim, ((int*)0p)`realloc );
    195         test_base(ip, size, libAlign);
    196         test_use(ip, size / elemSize);
    197         free(ip);
    198 
    199         ip = alloc( 0, ((int*)0p)`realloc );
    200         test_base(ip, 0, libAlign);
    201         free(ip);
    202 
    203         op = alloc( dim, ((int)0xdeadbeef)`fill );
     189        test_base( ip, 0, libAlign );
     190        free( ip );
     191
     192        ip = alloc( dim, 0p`realloc );
     193        test_base( ip, size, libAlign );
     194        test_use( ip, size / elemSize );
     195        free( ip );
     196
     197        ip = alloc( 0, 0p`realloc );
     198        test_base( ip, 0, libAlign );
     199        free( ip );
     200
     201        op = alloc( dim, 0xdeadbeefN`fill );
    204202        ip = alloc( dim, op`resize );
    205         test_base(ip, size, libAlign);
    206         test_use(ip, size / elemSize);
    207         free(ip);
     203        test_base( ip, size, libAlign );
     204        test_use( ip, size / elemSize );
     205        free( ip );
    208206
    209207        ip = alloc( FillC`fill );
    210         test_base(ip, elemSize, libAlign);
    211         test_fill(ip, 0, elemSize, FillC);
    212         test_use(ip, elemSize / elemSize);
    213         free(ip);
     208        test_base( ip, elemSize, libAlign );
     209        test_fill( ip, 0, elemSize, FillC );
     210        test_use( ip, elemSize / elemSize );
     211        free( ip );
    214212
    215213        ip = alloc( FillT`fill );
    216         test_base(ip, elemSize, libAlign);
    217         test_fill(ip, 0, 1, FillT);
    218         test_use(ip, elemSize / elemSize);
    219         free(ip);
     214        test_base( ip, elemSize, libAlign );
     215        test_fill( ip, 0, 1, FillT );
     216        test_use( ip, elemSize / elemSize );
     217        free( ip );
    220218
    221219        ip = alloc( dim, FillC`fill );
    222         test_base(ip, size, libAlign);
    223         test_fill(ip, 0, size, FillC);
    224         test_use(ip, size / elemSize);
    225         free(ip);
     220        test_base( ip, size, libAlign );
     221        test_fill( ip, 0, size, FillC );
     222        test_use( ip, size / elemSize );
     223        free( ip );
    226224
    227225        ip = alloc( 0, FillC`fill );
    228         test_base(ip, 0, libAlign);
    229         free(ip);
     226        test_base( ip, 0, libAlign );
     227        free( ip );
    230228
    231229        ip = alloc( dim, FillT`fill );
    232         test_base(ip, size, libAlign);
    233         test_fill(ip, 0, dim, FillT);
    234         test_use(ip, size / elemSize);
    235         free(ip);
     230        test_base( ip, size, libAlign );
     231        test_fill( ip, 0, dim, FillT );
     232        test_use( ip, size / elemSize );
     233        free( ip );
    236234
    237235        ip = alloc( 0, FillT`fill );
    238         test_base(ip, 0, libAlign);
    239         free(ip);
     236        test_base( ip, 0, libAlign );
     237        free( ip );
    240238
    241239        ip = alloc( dim, [FillA, dim/4]`fill );
    242         test_base(ip, size, libAlign);
    243         test_fill(ip, 0, size/4, FillA);
    244         test_use(ip, size / elemSize);
    245         free(ip);
     240        test_base( ip, size, libAlign );
     241        test_fill( ip, 0, size/4, FillA );
     242        test_use( ip, size / elemSize );
     243        free( ip );
    246244
    247245        ip = alloc( 0, [FillA, dim/4]`fill );
    248         test_base(ip, 0, libAlign);
    249         free(ip);
    250 
    251         op = alloc( dim, ((int)0xdeadbeef)`fill );
     246        test_base( ip, 0, libAlign );
     247        free( ip );
     248
     249        op = alloc( dim, 0xdeadbeefN`fill );
    252250        ip = alloc( dim, op`realloc, FillC`fill );
    253         test_base(ip, size, libAlign);
    254         test_fill(ip, 0, dim, (int)0xdeadbeef);
    255         test_use(ip, size / elemSize);
    256         free(ip);
    257 
    258         op = alloc( dim, ((int)0xdeadbeef)`fill );
     251        test_base( ip, size, libAlign );
     252        test_fill( ip, 0, dim, 0xdeadbeefN );
     253        test_use( ip, size / elemSize );
     254        free( ip );
     255
     256        op = alloc( dim, 0xdeadbeefN`fill );
    259257        ip = alloc( dim / 4, op`realloc, FillC`fill );
    260         test_base(ip, size / 4, libAlign);
    261         test_fill(ip, 0, dim / 4, (int)0xdeadbeef);
    262         test_use(ip, size / 4 / elemSize);
    263         free(ip);
    264 
    265         op = alloc( dim, ((int)0xdeadbeef)`fill );
     258        test_base( ip, size / 4, libAlign );
     259        test_fill( ip, 0, dim / 4, 0xdeadbeefN );
     260        test_use( ip, size / 4 / elemSize );
     261        free( ip );
     262
     263        op = alloc( dim, 0xdeadbeefN`fill );
    266264        ip = alloc( dim * 4, op`realloc, FillC`fill );
    267         test_base(ip, size * 4, libAlign);
    268         test_fill(ip, 0, dim, (int)0xdeadbeef);
    269         test_fill(ip, size, size * 4, FillC);
    270         test_use(ip, size * 4 / elemSize);
    271         free(ip);
    272 
    273         op = alloc( dim, ((int)0xdeadbeef)`fill );
     265        test_base( ip, size * 4, libAlign );
     266        test_fill( ip, 0, dim, 0xdeadbeefN );
     267        test_fill( ip, size, size * 4, FillC );
     268        test_use( ip, size * 4 / elemSize );
     269        free( ip );
     270
     271        op = alloc( dim, 0xdeadbeefN`fill );
    274272        ip = alloc( 0, op`realloc, FillC`fill );
    275         test_base(ip, 0, libAlign);
    276         free(ip);
    277 
    278         ip = alloc( dim, ((int*)0p)`realloc, FillC`fill );
    279         test_base(ip, size, libAlign);
    280         test_fill(ip, 0, size, FillC);
    281         test_use(ip, size / elemSize);
    282         free(ip);
    283 
    284         ip = alloc( 0, ((int*)0p)`realloc, FillC`fill );
    285         test_base(ip, 0, libAlign);
    286         free(ip);
    287 
    288         op = alloc( dim, ((int)0xdeadbeef)`fill );
     273        test_base( ip, 0, libAlign );
     274        free( ip );
     275
     276        ip = alloc( dim, 0p`realloc, FillC`fill );
     277        test_base( ip, size, libAlign );
     278        test_fill( ip, 0, size, FillC );
     279        test_use( ip, size / elemSize );
     280        free( ip );
     281
     282        ip = alloc( 0, 0p`realloc, FillC`fill );
     283        test_base( ip, 0, libAlign );
     284        free( ip );
     285
     286        op = alloc( dim, 0xdeadbeefN`fill );
    289287        ip = alloc( dim, op`realloc, FillT`fill );
    290         test_base(ip, size, libAlign);
    291         test_fill(ip, 0, dim, (int)0xdeadbeef);
    292         test_use(ip, size / elemSize);
    293         free(ip);
    294 
    295         op = alloc( dim, ((int)0xdeadbeef)`fill );
     288        test_base( ip, size, libAlign );
     289        test_fill( ip, 0, dim, 0xdeadbeefN );
     290        test_use( ip, size / elemSize );
     291        free( ip );
     292
     293        op = alloc( dim, 0xdeadbeefN`fill );
    296294        ip = alloc( dim / 4, op`realloc, FillT`fill );
    297         test_base(ip, size / 4, libAlign);
    298         test_fill(ip, 0, dim / 4, (int)0xdeadbeef);
    299         test_use(ip, size / 4 / elemSize);
    300         free(ip);
    301 
    302         op = alloc( dim, ((int)0xdeadbeef)`fill );
     295        test_base( ip, size / 4, libAlign );
     296        test_fill( ip, 0, dim / 4, 0xdeadbeefN );
     297        test_use( ip, size / 4 / elemSize );
     298        free( ip );
     299
     300        op = alloc( dim, 0xdeadbeefN`fill );
    303301        ip = alloc( dim * 4, op`realloc, FillT`fill );
    304         test_base(ip, size * 4, libAlign);
    305         test_fill(ip, 0, dim, (int)0xdeadbeef);
    306         test_fill(ip, dim, dim * 4, FillT);
    307         test_use(ip, size * 4 / elemSize);
    308         free(ip);
    309 
    310         op = alloc( dim, ((int)0xdeadbeef)`fill );
     302        test_base( ip, size * 4, libAlign );
     303        test_fill( ip, 0, dim, 0xdeadbeefN );
     304        test_fill( ip, dim, dim * 4, FillT );
     305        test_use( ip, size * 4 / elemSize );
     306        free( ip );
     307
     308        op = alloc( dim, 0xdeadbeefN`fill );
    311309        ip = alloc( 0, op`realloc, FillT`fill );
    312         test_base(ip, 0, libAlign);
    313         free(ip);
    314 
    315         ip = alloc( dim, ((int*)0p)`realloc, FillT`fill );
    316         test_base(ip, size, libAlign);
    317         test_fill(ip, 0, dim, FillT);
    318         test_use(ip, size / elemSize);
    319         free(ip);
    320 
    321         ip = alloc( 0, ((int*)0p)`realloc, FillT`fill );
    322         test_base(ip, 0, libAlign);
    323         free(ip);
     310        test_base( ip, 0, libAlign );
     311        free( ip );
     312
     313        ip = alloc( dim, 0p`realloc, FillT`fill );
     314        test_base( ip, size, libAlign );
     315        test_fill( ip, 0, dim, FillT );
     316        test_use( ip, size / elemSize );
     317        free( ip );
     318
     319        ip = alloc( 0, 0p`realloc, FillT`fill );
     320        test_base( ip, 0, libAlign );
     321        free( ip );
    324322
    325323        ip = alloc( align`align );
    326         test_base(ip, elemSize, align);
    327         test_use(ip, elemSize / elemSize);
    328         free(ip);
     324        test_base( ip, elemSize, align );
     325        test_use( ip, elemSize / elemSize );
     326        free( ip );
    329327
    330328        ip = alloc( dim, align`align );
    331         test_base(ip, size, align);
    332         test_use(ip, size / elemSize);
    333         free(ip);
     329        test_base( ip, size, align );
     330        test_use( ip, size / elemSize );
     331        free( ip );
    334332
    335333        ip = alloc( 0, align`align );
    336         test_base(ip, 0, libAlign);
    337         free(ip);
    338 
    339         op = alloc( dim, ((int)0xdeadbeef)`fill );
     334        test_base( ip, 0, libAlign );
     335        free( ip );
     336
     337        op = alloc( dim, 0xdeadbeefN`fill );
    340338        ip = alloc( op`realloc, align`align );
    341         test_base(ip, elemSize, align);
    342         test_fill(ip, 0, 1, (int)0xdeadbeef);
    343         test_use(ip, elemSize / elemSize);
    344         free(ip);
    345 
    346         ip = alloc( ((int*)0p)`realloc, align`align );
    347         test_base(ip, elemSize, align);
    348         test_use(ip, elemSize / elemSize);
    349         free(ip);
     339        test_base( ip, elemSize, align );
     340        test_fill( ip, 0, 1, 0xdeadbeefN );
     341        test_use( ip, elemSize / elemSize );
     342        free( ip );
     343
     344        ip = alloc( 0p`realloc, align`align );
     345        test_base( ip, elemSize, align );
     346        test_use( ip, elemSize / elemSize );
     347        free( ip );
    350348
    351349        dp = alloc( dim );
    352350        ip = alloc( dp`resize, align`align );
    353         test_base(ip, elemSize, align);
    354         test_use(ip, elemSize / elemSize);
    355         free(ip);
    356 
    357         ip = alloc( ((double*)0p)`resize, align`align );
    358         test_base(ip, elemSize, align);
    359         test_use(ip, elemSize / elemSize);
    360         free(ip);
    361 
    362         op = alloc( dim, ((int)0xdeadbeef)`fill);
     351        test_base( ip, elemSize, align );
     352        test_use( ip, elemSize / elemSize );
     353        free( ip );
     354
     355        ip = alloc( 0p`resize, align`align );
     356        test_base( ip, elemSize, align );
     357        test_use( ip, elemSize / elemSize );
     358        free( ip );
     359
     360        op = alloc( dim, 0xdeadbeefN`fill );
    363361        ip = alloc( dim, op`realloc, align`align );
    364         test_base(ip, size, align);
    365         test_fill(ip, 0, dim, (int)0xdeadbeef);
    366         test_use(ip, size / elemSize);
    367         free(ip);
    368 
    369         op = alloc( dim, ((int)0xdeadbeef)`fill );
     362        test_base( ip, size, align );
     363        test_fill( ip, 0, dim, 0xdeadbeefN );
     364        test_use( ip, size / elemSize );
     365        free( ip );
     366
     367        op = alloc( dim, 0xdeadbeefN`fill );
    370368        ip = alloc( 0, op`realloc, align`align );
    371         test_base(ip, 0, libAlign);
    372         free(ip);
    373 
    374         ip = alloc( dim, ((int*)0p)`realloc, align`align );
    375         test_base(ip, size, align);
    376         test_use(ip, size / elemSize);
    377         free(ip);
    378 
    379         ip = alloc( 0, ((int*)0p)`realloc, align`align );
    380         test_base(ip, 0, libAlign);
    381         free(ip);
     369        test_base( ip, 0, libAlign );
     370        free( ip );
     371
     372        ip = alloc( dim, 0p`realloc, align`align );
     373        test_base( ip, size, align );
     374        test_use( ip, size / elemSize );
     375        free( ip );
     376
     377        ip = alloc( 0, 0p`realloc, align`align );
     378        test_base( ip, 0, libAlign );
     379        free( ip );
    382380
    383381        ip = alloc( align`align, FillC`fill );
    384         test_base(ip, elemSize, align);
    385         test_fill(ip, 0, elemSize, FillC);
    386         test_use(ip, elemSize / elemSize);
    387         free(ip);
     382        test_base( ip, elemSize, align );
     383        test_fill( ip, 0, elemSize, FillC );
     384        test_use( ip, elemSize / elemSize );
     385        free( ip );
    388386
    389387        ip = alloc( align`align, FillT`fill );
    390         test_base(ip, elemSize, align);
    391         test_fill(ip, 0, 1, FillT);
    392         test_use(ip, elemSize / elemSize);
    393         free(ip);
     388        test_base( ip, elemSize, align );
     389        test_fill( ip, 0, 1, FillT );
     390        test_use( ip, elemSize / elemSize );
     391        free( ip );
    394392
    395393        ip = alloc( dim, align`align, FillC`fill );
    396         test_base(ip, size, align);
    397         test_fill(ip, 0, size, FillC);
    398         test_use(ip, size / elemSize);
    399         free(ip);
     394        test_base( ip, size, align );
     395        test_fill( ip, 0, size, FillC );
     396        test_use( ip, size / elemSize );
     397        free( ip );
    400398
    401399        ip = alloc( 0, align`align, FillC`fill );
    402         test_base(ip, 0, libAlign);
    403         free(ip);
     400        test_base( ip, 0, libAlign );
     401        free( ip );
    404402
    405403        ip = alloc( dim, align`align, FillT`fill );
    406         test_base(ip, size, align);
    407         test_fill(ip, 0, dim, FillT);
    408         test_use(ip, size / elemSize);
    409         free(ip);
     404        test_base( ip, size, align );
     405        test_fill( ip, 0, dim, FillT );
     406        test_use( ip, size / elemSize );
     407        free( ip );
    410408
    411409        ip = alloc( 0, align`align, FillT`fill );
    412         test_base(ip, 0, libAlign);
    413         free(ip);
     410        test_base( ip, 0, libAlign );
     411        free( ip );
    414412
    415413        ip = alloc( dim, align`align, [FillA, dim/4]`fill );
    416         test_base(ip, size, align);
    417         test_fill(ip, 0, size/4, FillA);
    418         test_use(ip, size / elemSize);
    419         free(ip);
     414        test_base( ip, size, align );
     415        test_fill( ip, 0, size/4, FillA );
     416        test_use( ip, size / elemSize );
     417        free( ip );
    420418
    421419        ip = alloc( 0, align`align, [FillA, dim/4]`fill );
    422         test_base(ip, 0, libAlign);
    423         free(ip);
    424 
    425         op = alloc( dim, ((int)0xdeadbeef)`fill );
     420        test_base( ip, 0, libAlign );
     421        free( ip );
     422
     423        op = alloc( dim, 0xdeadbeefN`fill );
    426424        ip = alloc( dim, op`realloc, align`align, FillC`fill );
    427         test_base(ip, size, align);
    428         test_fill(ip, 0, dim, (int)0xdeadbeef);
    429         test_use(ip, size / elemSize);
    430         free(ip);
    431 
    432         op = alloc( dim, ((int)0xdeadbeef)`fill );
     425        test_base( ip, size, align );
     426        test_fill( ip, 0, dim, 0xdeadbeefN );
     427        test_use( ip, size / elemSize );
     428        free( ip );
     429
     430        op = alloc( dim, 0xdeadbeefN`fill );
    433431        ip = alloc( dim / 4, op`realloc, align`align, FillC`fill );
    434         test_base(ip, size / 4, align);
    435         test_fill(ip, 0, dim / 4, (int)0xdeadbeef);
    436         test_use(ip, size / 4 / elemSize);
    437         free(ip);
    438 
    439         op = alloc( dim, ((int)0xdeadbeef)`fill );
     432        test_base( ip, size / 4, align );
     433        test_fill( ip, 0, dim / 4, 0xdeadbeefN );
     434        test_use( ip, size / 4 / elemSize );
     435        free( ip );
     436
     437        op = alloc( dim, 0xdeadbeefN`fill );
    440438        ip = alloc( dim * 4, op`realloc, align`align, FillC`fill );
    441         test_base(ip, size * 4, align);
    442         test_fill(ip, 0, dim, (int)0xdeadbeef);
    443         test_fill(ip, size, size * 4, FillC);
    444         test_use(ip, size * 4 / elemSize);
    445         free(ip);
    446 
    447         op = alloc( dim, ((int)0xdeadbeef)`fill );
     439        test_base( ip, size * 4, align );
     440        test_fill( ip, 0, dim, 0xdeadbeefN );
     441        test_fill( ip, size, size * 4, FillC );
     442        test_use( ip, size * 4 / elemSize );
     443        free( ip );
     444
     445        op = alloc( dim, 0xdeadbeefN`fill );
    448446        ip = alloc( 0, op`realloc, align`align, FillC`fill );
    449         test_base(ip, 0, libAlign);
    450         free(ip);
    451 
    452         ip = alloc( dim, ((int*)0p)`realloc, align`align, FillC`fill );
    453         test_base(ip, size, align);
    454         test_fill(ip, 0, size, FillC);
    455         test_use(ip, size / elemSize);
    456         free(ip);
    457 
    458         ip = alloc( 0, ((int*)0p)`realloc, align`align, FillC`fill );
    459         test_base(ip, 0, libAlign);
    460         free(ip);
    461 
    462         op = alloc( dim, ((int)0xdeadbeef)`fill );
     447        test_base( ip, 0, libAlign );
     448        free( ip );
     449
     450        ip = alloc( dim, 0p`realloc, align`align, FillC`fill );
     451        test_base( ip, size, align );
     452        test_fill( ip, 0, size, FillC );
     453        test_use( ip, size / elemSize );
     454        free( ip );
     455
     456        ip = alloc( 0, 0p`realloc, align`align, FillC`fill );
     457        test_base( ip, 0, libAlign );
     458        free( ip );
     459
     460        op = alloc( dim, 0xdeadbeefN`fill );
    463461        ip = alloc( dim, op`realloc, align`align, FillT`fill );
    464         test_base(ip, size, align);
    465         test_fill(ip, 0, dim, (int)0xdeadbeef);
    466         test_use(ip, size / elemSize);
    467         free(ip);
    468 
    469         op = alloc( dim, ((int)0xdeadbeef)`fill );
     462        test_base( ip, size, align );
     463        test_fill( ip, 0, dim, 0xdeadbeefN );
     464        test_use( ip, size / elemSize );
     465        free( ip );
     466
     467        op = alloc( dim, 0xdeadbeefN`fill );
    470468        ip = alloc( dim / 4, op`realloc, align`align, FillT`fill );
    471         test_base(ip, size / 4, align);
    472         test_fill(ip, 0, dim / 4, (int)0xdeadbeef);
    473         test_use(ip, size / 4 / elemSize);
    474         free(ip);
    475 
    476         op = alloc( dim, ((int)0xdeadbeef)`fill );
     469        test_base( ip, size / 4, align );
     470        test_fill( ip, 0, dim / 4, 0xdeadbeefN );
     471        test_use( ip, size / 4 / elemSize );
     472        free( ip );
     473
     474        op = alloc( dim, 0xdeadbeefN`fill );
    477475        ip = alloc( dim * 4, op`realloc, align`align, FillT`fill );
    478         test_base(ip, size * 4, align);
    479         test_fill(ip, 0, dim, (int)0xdeadbeef);
    480         test_fill(ip, dim, dim * 4, FillT);
    481         test_use(ip, size * 4 / elemSize);
    482         free(ip);
    483 
    484         op = alloc( dim, ((int)0xdeadbeef)`fill );
     476        test_base( ip, size * 4, align );
     477        test_fill( ip, 0, dim, 0xdeadbeefN );
     478        test_fill( ip, dim, dim * 4, FillT );
     479        test_use( ip, size * 4 / elemSize );
     480        free( ip );
     481
     482        op = alloc( dim, 0xdeadbeefN`fill );
    485483        ip = alloc( 0, op`realloc, align`align, FillT`fill );
    486         test_base(ip, 0, libAlign);
    487         free(ip);
    488 
    489         ip = alloc( dim, ((int*)0p)`realloc, align`align, FillT`fill );
    490         test_base(ip, size, align);
    491         test_fill(ip, 0, dim, FillT);
    492         test_use(ip, size / elemSize);
    493         free(ip);
    494 
    495         ip = alloc( 0, ((int*)0p)`realloc, align`align, FillT`fill );
    496         test_base(ip, 0, libAlign);
    497         free(ip);
    498 
    499         if (tests_failed == 0) printf("PASSED alloc tests\n\n");
    500         else printf("failed alloc tests : %d/%d\n\n", tests_failed, tests_total);
    501 
    502         // testing alloc (aligned struct)
     484        test_base( ip, 0, libAlign );
     485        free( ip );
     486
     487        ip = alloc( dim, 0p`realloc, align`align, FillT`fill );
     488        test_base( ip, size, align );
     489        test_fill( ip, 0, dim, FillT );
     490        test_use( ip, size / elemSize );
     491        free( ip );
     492
     493        ip = alloc( 0, 0p`realloc, align`align, FillT`fill );
     494        test_base( ip, 0, libAlign );
     495        free( ip );
     496
     497        if ( tests_failed == 0 ) printf( "PASSED alloc tests\n\n" );
     498        else printf( "failed alloc tests : %d/%d\n\n", tests_failed, tests_total );
     499
     500        // testing alloc ( aligned struct )
    503501
    504502        elemSize = sizeof(T1);
     
    509507
    510508        t1p = alloc();
    511         test_base(t1p, elemSize, tAlign);
    512         test_use(t1p, elemSize / elemSize);
    513         free(t1p);
     509        test_base( t1p, elemSize, tAlign );
     510        test_use( t1p, elemSize / elemSize );
     511        free( t1p );
    514512
    515513        t1p = alloc( dim );
    516         test_base(t1p, size, tAlign);
    517         test_use(t1p, size / elemSize);
    518         free(t1p);
     514        test_base( t1p, size, tAlign );
     515        test_use( t1p, size / elemSize );
     516        free( t1p );
    519517
    520518        t1p = alloc( 0 );
    521         test_base(t1p, 0, libAlign);
    522         free(t1p);
     519        test_base( t1p, 0, libAlign );
     520        free( t1p );
    523521
    524522        dp = alloc( dim );
    525523        t1p = alloc( dp`resize );
    526         test_base(t1p, elemSize, tAlign);
    527         test_use(t1p, elemSize / elemSize);
    528         free(t1p);
    529 
    530         t1p = alloc( ((double*)0p)`resize );
    531         test_base(t1p, elemSize, tAlign);
    532         test_use(t1p, elemSize / elemSize);
    533         free(t1p);
     524        test_base( t1p, elemSize, tAlign );
     525        test_use( t1p, elemSize / elemSize );
     526        free( t1p );
     527
     528        t1p = alloc( 0p`resize );
     529        test_base( t1p, elemSize, tAlign );
     530        test_use( t1p, elemSize / elemSize );
     531        free( t1p );
    534532
    535533        dp = alloc( dim );
    536534        t1p = alloc( dim, dp`resize );
    537         test_base(t1p, size, tAlign);
    538         test_use(t1p, size / elemSize);
    539         free(t1p);
     535        test_base( t1p, size, tAlign );
     536        test_use( t1p, size / elemSize );
     537        free( t1p );
    540538
    541539        dp = alloc( dim );
    542540        t1p = alloc( 0, dp`resize );
    543         test_base(t1p, 0, libAlign);
    544         free(t1p);
    545 
    546         t1p = alloc( dim, ((double*)0p)`resize );
    547         test_base(t1p, size, tAlign);
    548         test_use(t1p, size / elemSize);
    549         free(t1p);
    550 
    551         t1p = alloc( 0, ((double*)0p)`resize );
    552         test_base(t1p, 0, libAlign);
    553         free(t1p);
     541        test_base( t1p, 0, libAlign );
     542        free( t1p );
     543
     544        t1p = alloc( dim, 0p`resize );
     545        test_base( t1p, size, tAlign );
     546        test_use( t1p, size / elemSize );
     547        free( t1p );
     548
     549        t1p = alloc( 0, 0p`resize );
     550        test_base( t1p, 0, libAlign );
     551        free( t1p );
    554552
    555553        t1op = alloc( dim, ((T1){0xdeadbeef})`fill );
    556554        t1p = alloc( dim, t1op`realloc );
    557         test_base(t1p, size, tAlign);
    558         test_fill(t1p, 0, dim, (T1){0xdeadbeef});
    559         test_use(t1p, size / elemSize);
    560         free(t1p);
     555        test_base( t1p, size, tAlign );
     556        test_fill( t1p, 0, dim, (T1){0xdeadbeef});
     557        test_use( t1p, size / elemSize );
     558        free( t1p );
    561559
    562560        t1op = alloc( dim, ((T1){0xdeadbeef})`fill );
    563561        t1p = alloc( 0, t1op`realloc );
    564         test_base(t1p, 0, libAlign);
    565         free(t1p);
    566 
    567         t1p = alloc( dim, ((T1*)0p)`realloc );
    568         test_base(t1p, size, tAlign);
    569         test_use(t1p, size / elemSize);
    570         free(t1p);
    571 
    572         t1p = alloc( 0, ((T1*)0p)`realloc );
    573         test_base(t1p, 0, libAlign);
    574         free(t1p);
     562        test_base( t1p, 0, libAlign );
     563        free( t1p );
     564
     565        t1p = alloc( dim, 0p`realloc );
     566        test_base( t1p, size, tAlign );
     567        test_use( t1p, size / elemSize );
     568        free( t1p );
     569
     570        t1p = alloc( 0, 0p`realloc );
     571        test_base( t1p, 0, libAlign );
     572        free( t1p );
    575573
    576574        t1op = alloc( dim, ((T1){0xdeadbeef})`fill );
    577575        t1p = alloc( dim, t1op`resize );
    578         test_base(t1p, size, tAlign);
    579         test_use(t1p, size / elemSize);
    580         free(t1p);
     576        test_base( t1p, size, tAlign );
     577        test_use( t1p, size / elemSize );
     578        free( t1p );
    581579
    582580        t1p = alloc( FillC`fill );
    583         test_base(t1p, elemSize, tAlign);
    584         test_fill(t1p, 0, elemSize, FillC);
    585         test_use(t1p, elemSize / elemSize);
    586         free(t1p);
     581        test_base( t1p, elemSize, tAlign );
     582        test_fill( t1p, 0, elemSize, FillC );
     583        test_use( t1p, elemSize / elemSize );
     584        free( t1p );
    587585
    588586        t1p = alloc( FillT1`fill );
    589         test_base(t1p, elemSize, tAlign);
    590         test_fill(t1p, 0, 1, FillT1);
    591         test_use(t1p, elemSize / elemSize);
    592         free(t1p);
     587        test_base( t1p, elemSize, tAlign );
     588        test_fill( t1p, 0, 1, FillT1);
     589        test_use( t1p, elemSize / elemSize );
     590        free( t1p );
    593591
    594592        t1p = alloc( dim, FillC`fill );
    595         test_base(t1p, size, tAlign);
    596         test_fill(t1p, 0, size, FillC);
    597         test_use(t1p, size / elemSize);
    598         free(t1p);
     593        test_base( t1p, size, tAlign );
     594        test_fill( t1p, 0, size, FillC );
     595        test_use( t1p, size / elemSize );
     596        free( t1p );
    599597
    600598        t1p = alloc( 0, FillC`fill );
    601         test_base(t1p, 0, libAlign);
    602         free(t1p);
     599        test_base( t1p, 0, libAlign );
     600        free( t1p );
    603601
    604602        t1p = alloc( dim, FillT1`fill );
    605         test_base(t1p, size, tAlign);
    606         test_fill(t1p, 0, dim, FillT1);
    607         test_use(t1p, size / elemSize);
    608         free(t1p);
     603        test_base( t1p, size, tAlign );
     604        test_fill( t1p, 0, dim, FillT1);
     605        test_use( t1p, size / elemSize );
     606        free( t1p );
    609607
    610608        t1p = alloc( 0, FillT1`fill );
    611         test_base(t1p, 0, libAlign);
    612         free(t1p);
     609        test_base( t1p, 0, libAlign );
     610        free( t1p );
    613611
    614612        t1p = alloc( dim, [FillT1A, dim / 4]`fill );
    615         test_base(t1p, size, tAlign);
    616         test_fill(t1p, 0, size/4, FillT1A);
    617         test_use(t1p, size / elemSize);
    618         free(t1p);
     613        test_base( t1p, size, tAlign );
     614        test_fill( t1p, 0, size/4, FillT1A );
     615        test_use( t1p, size / elemSize );
     616        free( t1p );
    619617
    620618        t1p = alloc( 0, [FillT1A, dim / 4]`fill );
    621         test_base(t1p, 0, libAlign);
    622         free(t1p);
     619        test_base( t1p, 0, libAlign );
     620        free( t1p );
    623621
    624622        t1op = alloc( dim, ((T1){0xdeadbeef})`fill );
    625623        t1p = alloc( dim, t1op`realloc, FillC`fill );
    626         test_base(t1p, size, tAlign);
    627         test_fill(t1p, 0, dim, (T1){0xdeadbeef});
    628         test_use(t1p, size / elemSize);
    629         free(t1p);
     624        test_base( t1p, size, tAlign );
     625        test_fill( t1p, 0, dim, (T1){0xdeadbeef});
     626        test_use( t1p, size / elemSize );
     627        free( t1p );
    630628
    631629        t1op = alloc( dim, ((T1){0xdeadbeef})`fill );
    632630        t1p = alloc( dim / 4, t1op`realloc, FillC`fill );
    633         test_base(t1p, size / 4, tAlign);
    634         test_fill(t1p, 0, dim / 4, (T1){0xdeadbeef});
    635         test_use(t1p, size / 4 / elemSize);
    636         free(t1p);
     631        test_base( t1p, size / 4, tAlign );
     632        test_fill( t1p, 0, dim / 4, (T1){0xdeadbeef});
     633        test_use( t1p, size / 4 / elemSize );
     634        free( t1p );
    637635
    638636        t1op = alloc( dim, ((T1){0xdeadbeef})`fill );
    639637        t1p = alloc( dim * 4, t1op`realloc, FillC`fill );
    640         test_base(t1p, size * 4, tAlign);
    641         test_fill(t1p, 0, dim, (T1){0xdeadbeef});
    642         test_fill(t1p, size, size * 4, FillC);
    643         test_use(t1p, size * 4 / elemSize);
    644         free(t1p);
     638        test_base( t1p, size * 4, tAlign );
     639        test_fill( t1p, 0, dim, (T1){0xdeadbeef});
     640        test_fill( t1p, size, size * 4, FillC );
     641        test_use( t1p, size * 4 / elemSize );
     642        free( t1p );
    645643
    646644        t1op = alloc( dim, ((T1){0xdeadbeef})`fill );
    647645        t1p = alloc( 0, t1op`realloc, FillC`fill );
    648         test_base(t1p, 0, libAlign);
    649         free(t1p);
    650 
    651         t1p = alloc( dim, ((T1*)0p)`realloc, FillC`fill );
    652         test_base(t1p, size, tAlign);
    653         test_fill(t1p, 0, size, FillC);
    654         test_use(t1p, size / elemSize);
    655         free(t1p);
    656 
    657         t1p = alloc( 0, ((T1*)0p)`realloc, FillC`fill );
    658         test_base(t1p, 0, libAlign);
    659         free(t1p);
     646        test_base( t1p, 0, libAlign );
     647        free( t1p );
     648
     649        t1p = alloc( dim, 0p`realloc, FillC`fill );
     650        test_base( t1p, size, tAlign );
     651        test_fill( t1p, 0, size, FillC );
     652        test_use( t1p, size / elemSize );
     653        free( t1p );
     654
     655        t1p = alloc( 0, 0p`realloc, FillC`fill );
     656        test_base( t1p, 0, libAlign );
     657        free( t1p );
    660658
    661659        t1op = alloc( dim, ((T1){0xdeadbeef})`fill );
    662660        t1p = alloc( dim, t1op`realloc, FillT1`fill );
    663         test_base(t1p, size, tAlign);
    664         test_fill(t1p, 0, dim, (T1){0xdeadbeef});
    665         test_use(t1p, size / elemSize);
    666         free(t1p);
     661        test_base( t1p, size, tAlign );
     662        test_fill( t1p, 0, dim, (T1){0xdeadbeef});
     663        test_use( t1p, size / elemSize );
     664        free( t1p );
    667665
    668666        t1op = alloc( dim, ((T1){0xdeadbeef})`fill );
    669667        t1p = alloc( dim / 4, t1op`realloc, FillT1`fill );
    670         test_base(t1p, size / 4, tAlign);
    671         test_fill(t1p, 0, dim / 4, (T1){0xdeadbeef});
    672         test_use(t1p, size / 4 / elemSize);
    673         free(t1p);
     668        test_base( t1p, size / 4, tAlign );
     669        test_fill( t1p, 0, dim / 4, (T1){0xdeadbeef});
     670        test_use( t1p, size / 4 / elemSize );
     671        free( t1p );
    674672
    675673        t1op = alloc( dim, ((T1){0xdeadbeef})`fill );
    676674        t1p = alloc( dim * 4, t1op`realloc, FillT1`fill );
    677         test_base(t1p, size * 4, tAlign);
    678         test_fill(t1p, 0, dim, (T1){0xdeadbeef});
    679         test_fill(t1p, dim, dim * 4, FillT1);
    680         test_use(t1p, size * 4 / elemSize);
    681         free(t1p);
     675        test_base( t1p, size * 4, tAlign );
     676        test_fill( t1p, 0, dim, (T1){0xdeadbeef});
     677        test_fill( t1p, dim, dim * 4, FillT1);
     678        test_use( t1p, size * 4 / elemSize );
     679        free( t1p );
    682680
    683681        t1op = alloc( dim, ((T1){0xdeadbeef})`fill );
    684682        t1p = alloc( 0, t1op`realloc, FillT1`fill );
    685         test_base(t1p, 0, libAlign);
    686         free(t1p);
    687 
    688         t1p = alloc( dim, ((T1*)0p)`realloc, FillT1`fill );
    689         test_base(t1p, size, tAlign);
    690         test_fill(t1p, 0, dim, FillT1);
    691         test_use(t1p, size / elemSize);
    692         free(t1p);
    693 
    694         t1p = alloc( 0, ((T1*)0p)`realloc, FillT1`fill );
    695         test_base(t1p, 0, libAlign);
    696         free(t1p);
     683        test_base( t1p, 0, libAlign );
     684        free( t1p );
     685
     686        t1p = alloc( dim, 0p`realloc, FillT1`fill );
     687        test_base( t1p, size, tAlign );
     688        test_fill( t1p, 0, dim, FillT1);
     689        test_use( t1p, size / elemSize );
     690        free( t1p );
     691
     692        t1p = alloc( 0, 0p`realloc, FillT1`fill );
     693        test_base( t1p, 0, libAlign );
     694        free( t1p );
    697695
    698696        t1p = alloc( align`align );
    699         test_base(t1p, elemSize, align);
    700         test_use(t1p, elemSize / elemSize);
    701         free(t1p);
     697        test_base( t1p, elemSize, align );
     698        test_use( t1p, elemSize / elemSize );
     699        free( t1p );
    702700
    703701        t1p = alloc( dim, align`align );
    704         test_base(t1p, size, align);
    705         test_use(t1p, size / elemSize);
    706         free(t1p);
     702        test_base( t1p, size, align );
     703        test_use( t1p, size / elemSize );
     704        free( t1p );
    707705
    708706        t1p = alloc( 0, align`align );
    709         test_base(t1p, 0, libAlign);
    710         free(t1p);
     707        test_base( t1p, 0, libAlign );
     708        free( t1p );
    711709
    712710        t1op = alloc( dim, ((T1){0xdeadbeef})`fill );
    713711        t1p = alloc( t1op`realloc, align`align );
    714         test_base(t1p, elemSize, align);
    715         test_fill(t1p, 0, 1, (T1){0xdeadbeef});
    716         test_use(t1p, elemSize / elemSize);
    717         free(t1p);
    718 
    719         t1p = alloc( ((T1*)0p)`realloc, align`align );
    720         test_base(t1p, elemSize, align);
    721         test_use(t1p, elemSize / elemSize);
    722         free(t1p);
     712        test_base( t1p, elemSize, align );
     713        test_fill( t1p, 0, 1, (T1){0xdeadbeef});
     714        test_use( t1p, elemSize / elemSize );
     715        free( t1p );
     716
     717        t1p = alloc( 0p`realloc, align`align );
     718        test_base( t1p, elemSize, align );
     719        test_use( t1p, elemSize / elemSize );
     720        free( t1p );
    723721
    724722        dp = alloc( dim );
    725723        t1p = alloc( dp`resize, align`align );
    726         test_base(t1p, elemSize, align);
    727         test_use(t1p, elemSize / elemSize);
    728         free(t1p);
    729 
    730         t1p = alloc( ((double*)0p)`resize, align`align );
    731         test_base(t1p, elemSize, align);
    732         test_use(t1p, elemSize / elemSize);
    733         free(t1p);
     724        test_base( t1p, elemSize, align );
     725        test_use( t1p, elemSize / elemSize );
     726        free( t1p );
     727
     728        t1p = alloc( 0p`resize, align`align );
     729        test_base( t1p, elemSize, align );
     730        test_use( t1p, elemSize / elemSize );
     731        free( t1p );
    734732
    735733        t1op = alloc( dim, ((T1){0xdeadbeef})`fill );
    736734        t1p = alloc( dim, t1op`realloc, align`align );
    737         test_base(t1p, size, align);
    738         test_fill(t1p, 0, dim, (T1){0xdeadbeef});
    739         test_use(t1p, size / elemSize);
    740         free(t1p);
     735        test_base( t1p, size, align );
     736        test_fill( t1p, 0, dim, (T1){0xdeadbeef});
     737        test_use( t1p, size / elemSize );
     738        free( t1p );
    741739
    742740        t1op = alloc( dim, ((T1){0xdeadbeef})`fill );
    743741        t1p = alloc( 0, t1op`realloc, align`align );
    744         test_base(t1p, 0, libAlign);
    745         free(t1p);
    746 
    747         t1p = alloc( dim, ((T1*)0p)`realloc, align`align );
    748         test_base(t1p, size, align);
    749         test_use(t1p, size / elemSize);
    750         free(t1p);
    751 
    752         t1p = alloc( 0, ((T1*)0p)`realloc, align`align );
    753         test_base(t1p, 0, libAlign);
    754         free(t1p);
     742        test_base( t1p, 0, libAlign );
     743        free( t1p );
     744
     745        t1p = alloc( dim, 0p`realloc, align`align );
     746        test_base( t1p, size, align );
     747        test_use( t1p, size / elemSize );
     748        free( t1p );
     749
     750        t1p = alloc( 0, 0p`realloc, align`align );
     751        test_base( t1p, 0, libAlign );
     752        free( t1p );
    755753
    756754        t1p = alloc( align`align, FillC`fill );
    757         test_base(t1p, elemSize, align);
    758         test_fill(t1p, 0, elemSize, FillC);
    759         test_use(t1p, elemSize / elemSize);
    760         free(t1p);
     755        test_base( t1p, elemSize, align );
     756        test_fill( t1p, 0, elemSize, FillC );
     757        test_use( t1p, elemSize / elemSize );
     758        free( t1p );
    761759
    762760        t1p = alloc( align`align, FillT1`fill );
    763         test_base(t1p, elemSize, align);
    764         test_fill(t1p, 0, 1, FillT1);
    765         test_use(t1p, elemSize / elemSize);
    766         free(t1p);
     761        test_base( t1p, elemSize, align );
     762        test_fill( t1p, 0, 1, FillT1);
     763        test_use( t1p, elemSize / elemSize );
     764        free( t1p );
    767765
    768766        t1p = alloc( dim, align`align, FillC`fill );
    769         test_base(t1p, size, align);
    770         test_fill(t1p, 0, size, FillC);
    771         test_use(t1p, size / elemSize);
    772         free(t1p);
     767        test_base( t1p, size, align );
     768        test_fill( t1p, 0, size, FillC );
     769        test_use( t1p, size / elemSize );
     770        free( t1p );
    773771
    774772        t1p = alloc( 0, align`align, FillC`fill );
    775         test_base(t1p, 0, libAlign);
    776         free(t1p);
     773        test_base( t1p, 0, libAlign );
     774        free( t1p );
    777775
    778776        t1p = alloc( dim, align`align, FillT1`fill );
    779         test_base(t1p, size, align);
    780         test_fill(t1p, 0, dim, FillT1);
    781         test_use(t1p, size / elemSize);
    782         free(t1p);
     777        test_base( t1p, size, align );
     778        test_fill( t1p, 0, dim, FillT1);
     779        test_use( t1p, size / elemSize );
     780        free( t1p );
    783781
    784782        t1p = alloc( 0, align`align, FillT1`fill );
    785         test_base(t1p, 0, libAlign);
    786         free(t1p);
     783        test_base( t1p, 0, libAlign );
     784        free( t1p );
    787785
    788786        t1p = alloc( dim, align`align, [FillT1A, dim / 4]`fill );
    789         test_base(t1p, size, align);
    790         test_fill(t1p, 0, size/4, FillT1A);
    791         test_use(t1p, size / elemSize);
    792         free(t1p);
     787        test_base( t1p, size, align );
     788        test_fill( t1p, 0, size/4, FillT1A );
     789        test_use( t1p, size / elemSize );
     790        free( t1p );
    793791
    794792        t1p = alloc( 0, align`align, [FillT1A, dim / 4]`fill );
    795         test_base(t1p, 0, libAlign);
    796         free(t1p);
     793        test_base( t1p, 0, libAlign );
     794        free( t1p );
    797795
    798796        t1op = alloc( dim, ((T1){0xdeadbeef})`fill );
    799797        t1p = alloc( dim, t1op`realloc, align`align, FillC`fill );
    800         test_base(t1p, size, align);
    801         test_fill(t1p, 0, dim, (T1){0xdeadbeef});
    802         test_use(t1p, size / elemSize);
    803         free(t1p);
     798        test_base( t1p, size, align );
     799        test_fill( t1p, 0, dim, (T1){0xdeadbeef});
     800        test_use( t1p, size / elemSize );
     801        free( t1p );
    804802
    805803        t1op = alloc( dim, ((T1){0xdeadbeef})`fill );
    806804        t1p = alloc( dim / 4, t1op`realloc, align`align, FillC`fill );
    807         test_base(t1p, size / 4, align);
    808         test_fill(t1p, 0, dim / 4, (T1){0xdeadbeef});
    809         test_use(t1p, size / 4 / elemSize);
    810         free(t1p);
     805        test_base( t1p, size / 4, align );
     806        test_fill( t1p, 0, dim / 4, (T1){0xdeadbeef});
     807        test_use( t1p, size / 4 / elemSize );
     808        free( t1p );
    811809
    812810        t1op = alloc( dim, ((T1){0xdeadbeef})`fill );
    813811        t1p = alloc( dim * 4, t1op`realloc, align`align, FillC`fill );
    814         test_base(t1p, size * 4, align);
    815         test_fill(t1p, 0, dim, (T1){0xdeadbeef});
    816         test_fill(t1p, size, size * 4, FillC);
    817         test_use(t1p, size * 4 / elemSize);
    818         free(t1p);
     812        test_base( t1p, size * 4, align );
     813        test_fill( t1p, 0, dim, (T1){0xdeadbeef});
     814        test_fill( t1p, size, size * 4, FillC );
     815        test_use( t1p, size * 4 / elemSize );
     816        free( t1p );
    819817
    820818        t1op = alloc( dim, ((T1){0xdeadbeef})`fill );
    821819        t1p = alloc( 0, t1op`realloc, align`align, FillC`fill );
    822         test_base(t1p, 0, libAlign);
    823         free(t1p);
    824 
    825         t1p = alloc( dim, ((T1*)0p)`realloc, align`align, FillC`fill );
    826         test_base(t1p, size, align);
    827         test_fill(t1p, 0, size, FillC);
    828         test_use(t1p, size / elemSize);
    829         free(t1p);
    830 
    831         t1p = alloc( 0, ((T1*)0p)`realloc, align`align, FillC`fill );
    832         test_base(t1p, 0, libAlign);
    833         free(t1p);
    834 
    835         t1op = alloc( dim, ((T1){0xdeadbeef})`fill);
     820        test_base( t1p, 0, libAlign );
     821        free( t1p );
     822
     823        t1p = alloc( dim, 0p`realloc, align`align, FillC`fill );
     824        test_base( t1p, size, align );
     825        test_fill( t1p, 0, size, FillC );
     826        test_use( t1p, size / elemSize );
     827        free( t1p );
     828
     829        t1p = alloc( 0, 0p`realloc, align`align, FillC`fill );
     830        test_base( t1p, 0, libAlign );
     831        free( t1p );
     832
     833        t1op = alloc( dim, ((T1){0xdeadbeef})`fill );
    836834        t1p = alloc( dim, t1op`realloc, align`align, FillT1`fill );
    837         test_base(t1p, size, align);
    838         test_fill(t1p, 0, dim, (T1){0xdeadbeef});
    839         test_use(t1p, size / elemSize);
    840         free(t1p);
     835        test_base( t1p, size, align );
     836        test_fill( t1p, 0, dim, (T1){0xdeadbeef});
     837        test_use( t1p, size / elemSize );
     838        free( t1p );
    841839
    842840        t1op = alloc( dim, ((T1){0xdeadbeef})`fill );
    843841        t1p = alloc( dim / 4, t1op`realloc, align`align, FillT1`fill );
    844         test_base(t1p, size / 4, align);
    845         test_fill(t1p, 0, dim / 4, (T1){0xdeadbeef});
    846         test_use(t1p, size / 4 / elemSize);
    847         free(t1p);
     842        test_base( t1p, size / 4, align );
     843        test_fill( t1p, 0, dim / 4, (T1){0xdeadbeef});
     844        test_use( t1p, size / 4 / elemSize );
     845        free( t1p );
    848846
    849847        t1op = alloc( dim, ((T1){0xdeadbeef})`fill );
    850848        t1p = alloc( dim * 4, t1op`realloc, align`align, FillT1`fill );
    851         test_base(t1p, size * 4, align);
    852         test_fill(t1p, 0, dim, (T1){0xdeadbeef});
    853         test_fill(t1p, dim, dim * 4, FillT1);
    854         test_use(t1p, size * 4 / elemSize);
    855         free(t1p);
     849        test_base( t1p, size * 4, align );
     850        test_fill( t1p, 0, dim, (T1){0xdeadbeef});
     851        test_fill( t1p, dim, dim * 4, FillT1);
     852        test_use( t1p, size * 4 / elemSize );
     853        free( t1p );
    856854
    857855        t1op = alloc( dim, ((T1){0xdeadbeef})`fill );
    858856        t1p = alloc( 0, t1op`realloc, align`align, FillT1`fill );
    859         test_base(t1p, 0, libAlign);
    860         free(t1p);
    861 
    862         t1p = alloc( dim, ((T1*)0p)`realloc, align`align, FillT1`fill );
    863         test_base(t1p, size, align);
    864         test_fill(t1p, 0, dim, FillT1);
    865         test_use(t1p, size / elemSize);
    866         free(t1p);
    867 
    868         t1p = alloc( 0, ((T1*)0p)`realloc, align`align, FillT1`fill );
    869         test_base(t1p, 0, libAlign);
    870         free(t1p);
    871 
    872         if (tests_failed == 0) printf("PASSED alloc tests (aligned struct)\n\n");
    873         else printf("failed alloc tests (aligned struct) : %d/%d\n\n", tests_failed, tests_total);
    874 
    875         printf("(if applicable) alignment error below indicates memory trashing caused by test_use.\n\n");
    876         free(FillA);
    877         free(FillT1A);
    878         return 0;
     857        test_base( t1p, 0, libAlign );
     858        free( t1p );
     859
     860        t1p = alloc( dim, 0p`realloc, align`align, FillT1`fill );
     861        test_base( t1p, size, align );
     862        test_fill( t1p, 0, dim, FillT1);
     863        test_use( t1p, size / elemSize );
     864        free( t1p );
     865
     866        t1p = alloc( 0, 0p`realloc, align`align, FillT1`fill );
     867        test_base( t1p, 0, libAlign );
     868        free( t1p );
     869
     870        if ( tests_failed == 0) printf( "PASSED alloc tests (aligned struct)\n\n");
     871        else printf( "failed alloc tests ( aligned struct ) : %d/%d\n\n", tests_failed, tests_total );
     872
     873        printf( "(if applicable) alignment error below indicates memory trashing caused by test_use.\n\n");
     874        free( FillA );
     875        free( FillT1A );
    879876} // main
Note: See TracChangeset for help on using the changeset viewer.