int *a = new int[0];
...
delete[] a;
However, the source code for operator new[]() shows that it checks to
see if the block size is 0, then set it to 1 if so... so it should
work!
Did anyone encounter such a problem, and could give any advice? I
don't want to check all my `new's to see which ones could allocate
empty blocks....
Thanks,
Hugues.
--
Hugues MARTY: ISoft, Chemin de Moulon, F-91190 Gif-sur-Yvette, France
E-mail: hug...@isoft.fr / Phone: +33 1 6941 2777 / Fax: +33 1 6941 2532
Hi Hugues,
Just curious, why would you allocate new int[0] in the first place ?
>Hugues Marty wrote:
[...]
>> int *a = new int[0];
>> ...
>> delete[] a;
>>
>> However, the source code for operator new[]() shows that it checks to
>> see if the block size is 0, then set it to 1 if so... so it should
>> work!
>>
>> Did anyone encounter such a problem, and could give any advice? I
>> don't want to check all my `new's to see which ones could allocate
>> empty blocks....
[...]
>Just curious, why would you allocate new int[0] in the first place ?
Perhaps to handle the general case?
int n = 0;
int* a = n ? new int [n] : 0;
Should do it.
This is not a problem of BC++, it happens on other systems too.
-- Jean-Claude
______________________________________________________________________
Jean-Claude Wippler http://purl.net/meta4
Meta Four Software CatFish - A freeware disk catalog browser
j...@meta4.nl <ASP> MetaKit - C++ library for persistent data
But it is legal C++ syntax [to new int[0]] and should work on all
compilers calling
themself C++ compilers.
> -- Jean-Claude
Cheers
Andreas
--
Andreas Arff
mailto:a...@ergosoft.no or mailto:and...@online.no
I am just a boring sig