Changeset 0f7a0ea for libcfa


Ignore:
Timestamp:
Dec 8, 2020, 6:40:10 PM (4 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
48f6252
Parents:
d6089ad
Message:

[fixes #228] delete of 0-sized object always calls destructor; always call free

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/stdlib.hfa

    rd6089ad r0f7a0ea  
    1010// Created On       : Thu Jan 28 17:12:35 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Nov 12 20:58:48 2020
    13 // Update Count     : 520
     12// Last Modified On : Tue Dec  8 18:27:22 2020
     13// Update Count     : 524
    1414//
    1515
     
    268268static inline forall( dtype T | { void ^?{}( T & ); } )
    269269void delete( T * ptr ) {
    270         if ( ptr ) {                                                                            // ignore null
     270        // special case for 0-sized object => always call destructor
     271        if ( ptr || sizeof(ptr) == 0 ) {                                        // ignore null but not 0-sized objects
    271272                ^(*ptr){};                                                                              // run destructor
    272                 free( ptr );
    273273        } // if
     274        free( ptr );
    274275} // delete
    275276
Note: See TracChangeset for help on using the changeset viewer.