On 10/17/12 02:35, Daniel Lehman wrote: @@ -7241,10 +7241,11 @@ void __thiscall locale__Locimp_dtor(locale__Locimp *this) MSVCP_size_t i; for(i=0; i<this->facet_cnt; i++) if(this->facetvec[i] && locale_facet__Decref(this->facetvec[i])) - call_locale_facet_vector_dtor(this->facetvec[i], 0); + call_locale_facet_vector_dtor(this->facetvec[i], 1);
MSVCRT_operator_delete(this->facetvec); MSVCP_basic_string_char_dtor(&this->name); + MSVCRT_operator_delete(this); } } Memory allocated for locale__Locimp object should be freed in locale class (locale_dtor function). You can't delete it here.
Cheers, Piotr
Memory allocated for locale__Locimp object should be freed in locale class (locale_dtor function). You can't delete it here.
Yeah, wasn't entirely sure about the location, but I want to call delete as soon as the refcount is 0 and can only reliably do that there. locale_dtor can't count on refcount when multiple threads are used. should I change locale__Locimp_dtor to return true if locale_dtor should call delete?
Thanks daniel
On 10/17/12 5:04 PM, Daniel Lehman wrote:
Memory allocated for locale__Locimp object should be freed in locale class (locale_dtor function). You can't delete it here.
Yeah, wasn't entirely sure about the location, but I want to call delete as soon as the refcount is 0 and can only reliably do that there. locale_dtor can't count on refcount when multiple threads are used. should I change locale__Locimp_dtor to return true if locale_dtor should call delete?
You can't add return value to locale__Locimp_dtor since it have to be compatible with what native returns. I'm not sure how it's supposed to work, I guess locale__Locimp_dtor should be only called when refcount already is 0. I'll do some testing tomorrow.
Cheers, Piotr
You can't add return value to locale__Locimp_dtor since it have to be compatible with what native returns. I'm not sure how it's supposed to work, I guess locale__Locimp_dtor should be only called when refcount already is 0. I'll do some testing tomorrow.
How about something like the attached?
It moves the call to _Decref up to locale_dtor, so _Locimp_dtor isn't even called if the refcount is non-zero
once it does hit zero, it both calls _Locimp_dtor followed by the delete
Thanks daniel
On 10/17/12 19:20, Daniel Lehman wrote:
How about something like the attached?
Looks good for me. I would add base class destruction in _Locimp_dtor (locale::facet class). It's an empty function, but it's probably good to call it anyway, so if something changes in future it will be less likely to make mistakes here.
Thanks, Piotr