[Patch] Fix libstdc++/12352 (continued)
Paolo Carlini
pcarlini@unitus.it
Sun Sep 28 17:21:00 GMT 2003
Pétur Runólfsson wrote:
>There still appear to be memory leaks in the constructor
>
> locale::_Impl::
> _Impl(const char* __s, size_t __refs)
> : _M_references(__refs), _M_facets_size(_GLIBCXX_NUM_FACETS)
>
>At least, __cloc appears to be leaked if an exception is thrown,
>and if exceptions are thrown from the lines that look like
>
> _M_init_facet(new std::collate<char>(__cloc));
>
>then all memory allocated up to that point is leaked.
>
>This should be detectable with the testcase I attached to the PR
>if the outer loop is run often enough.
>
Hi!
The below is supposed to address Pétur's concerns. Basically,
I wrapped all the _M_init_facet calls in the try block (in order
to do that I had to tweak slightly the order of the new vs the
assignments for _M_facets, _M_caches and _M_names, and also the
destructor, adding checks for null pointers) and also dealt with
__cloc. Besides running the testsuite, I tried Pétur's testcase
with command line values up to 200000.
Pétur, Gaby, do you agree that it's a further improvement?
Thanks,
Paolo.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: CL_12352_cont
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20030928/01dd70fa/attachment.ksh>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: patch_12352_cont
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20030928/01dd70fa/attachment-0001.ksh>
More information about the Libstdc++
mailing list