Changeset 1911f37


Ignore:
Timestamp:
Sep 24, 2025, 6:23:34 PM (101 minutes ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
master
Children:
2d743bd
Parents:
2df85ce
Message:

formatting, add tests for new anew/adelete

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/stdlib.cfa

    r2df85ce r1911f37  
    1010// Created On       : Thu Jan 28 17:10:29 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Sep 24 18:01:01 2025
    13 // Update Count     : 759
     12// Last Modified On : Wed Sep 24 18:14:20 2025
     13// Update Count     : 760
    1414//
    1515
     
    4646forall( T & | sized(T) | { void ^?{}( T & ); } )
    4747void adelete( T arr[] ) {
    48         if ( arr == 0p ) return;                                                        // 0p ? special case
     48  if ( arr == 0p ) return;                                                              // 0p ? special case
    4949        size_t dim = sizeof( T ) == 0 ? (size_t)(*(size_t *)arr) : malloc_size( arr ) / sizeof( T ); // compute dimension
    5050        for ( i; 0 -~= dim - 1 ) {                                                      // reverse allocation order, must be signed
     
    6565
    6666bool checkif( const char s[], int (* kind)( int ) ) {
    67         for () {
     67        for () {                                                                                        // at least 1 character '\0'
    6868          if ( *s == '\0' ) return true;
    6969          if ( ! kind( *s ) ) return false;
     
    7373
    7474bool checkif( const char s[], int (* kind)( int, locale_t ), locale_t locale ) {
    75         for () {
     75        for () {                                                                                        // at least 1 character '\0'
    7676          if ( *s == '\0' ) return true;
    7777          if ( ! kind( *s, locale ) ) return false;
  • tests/.expect/alloc.txt

    r2df85ce r1911f37  
    767642 42.5, 42 42.5, 42 42.5, 42 42.5, 42 42.5, 42 42.5, 42 42.5, 42 42.5, 42 42.5, 42 42.5,
    777742 42.5, 42 42.5, 42 42.5, 42 42.5, 42 42.5, 42 42.5, 42 42.5, 42 42.5, 42 42.5, 42 42.5,
     78ctor
     79ctor
     80ctor
     81ctor
     82ctor
     83ctor
     84ctor
     85ctor
     86ctor
     87ctor
     88ctor
     89ctor
     90ctor
     91ctor
     92ctor
     93dtor
     94dtor
     95dtor
     96dtor
     97dtor
     98dtor
     99dtor
     100dtor
     101dtor
     102dtor
     103dtor
     104dtor
     105dtor
     106dtor
     107dtor
    78108
    79109pointer arithmetic 0
  • tests/alloc.cfa

    r2df85ce r1911f37  
    1010// Created On       : Wed Feb  3 07:56:22 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Apr 23 14:04:11 2024
    13 // Update Count     : 492
     12// Last Modified On : Wed Sep 24 18:21:09 2025
     13// Update Count     : 493
    1414//
    1515
     
    362362        assert( const_count == 2 + 2 * dim && dest_count == 2 + 2 * dim); // assertion for testing
    363363
     364        struct Empty {};
     365        void ?{}( Empty & ) { sout | "ctor"; }
     366        void ^?{}( Empty & ) { sout | "dtor"; }
     367        Empty * ea1 = anew( 5 );
     368        Empty * ea2 = anew( 5 );
     369        Empty * ea3 = anew( 5 );
     370        adelete( ea1, ea2, ea3 );
     371
    364372        // extras
    365373        sout | nl;
Note: See TracChangeset for help on using the changeset viewer.