Changeset 234c432 for libcfa


Ignore:
Timestamp:
Apr 10, 2025, 6:06:23 PM (5 months ago)
Author:
Michael Brooks <mlbrooks@…>
Branches:
master
Children:
831b2ec
Parents:
b1b513d
Message:

Reorder string quasi-lifecycle functions to ensure string dtor called by all static-inline implementations.

This situation is not exercised currently, but will be, upon upcoming string-overload reorganizations. Incumbent tests are adequate to show if a static-inline change misses the custom dtor: have observed "allocated but not freed" failures from test.py.

Doing this code-move ahead of the string-overload reorganizations keeps them more standalone.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/collections/string.hfa

    rb1b513d r234c432  
    2323};
    2424
    25 // Getters
    26 static inline size_t len( const string & s ) { return len( *s.inner ); }
    27 static inline size_t len( const char * cs ) { return strlen( cs ); };
    28 static inline size_t strlen( const string & s ) { return len( s ); }
    29 
    3025// RAII, assignment
     26void ^?{}( string & s );
     27
    3128void ?{}( string & s );                                                                 // empty string
    3229void ?{}( string & s, const string & s2 );
     
    5855string & assign( string & s, const string & c, size_t n );
    5956string & assign( string & s, const char * c, size_t n );
    60 
    61 static inline string & strcpy( string & s, const char * c ) { s = c; return s; }
    62 static inline string & strncpy( string & s, const char * c, size_t n ) { assign( s, c, n ); return s; }
    63 static inline string & strcpy( string & s, const string & c ) { s = c; return s; }
    64 static inline string & strncpy( string & s, const string & c, size_t n ) { assign( s, c, n ); return s; }
    65 
    6657string & ?=?( string & s, ssize_t rhs );
    6758string & ?=?( string & s, size_t rhs );
     
    7162string & ?=?( string & s, long double _Complex rhs );
    7263
    73 void ^?{}( string & s );
     64static inline string & strcpy( string & s, const char * c ) { s = c; return s; }
     65static inline string & strncpy( string & s, const char * c, size_t n ) { assign( s, c, n ); return s; }
     66static inline string & strcpy( string & s, const string & c ) { s = c; return s; }
     67static inline string & strncpy( string & s, const string & c, size_t n ) { assign( s, c, n ); return s; }
    7468
    7569// Alternate construction: request shared edits
     
    7973string_Share ?`share( string & s );
    8074void ?{}( string & s, string_Share src );
     75
     76// Getters
     77static inline size_t len( const string & s ) { return len( *s.inner ); }
     78static inline size_t len( const char * cs ) { return strlen( cs ); };
     79static inline size_t strlen( const string & s ) { return len( s ); }
    8180
    8281// IO Operator
Note: See TracChangeset for help on using the changeset viewer.