Re: realloc
pete wrote:[color=blue]
> Flash Gordon wrote:
>
>[color=green]
>> /* improve chances of the fputs not running out of memory */[/color]
>
>
> #include <stdio.h>
>
> int fput_s(const char *s, FILE *stream);
>
> int main(void)
> {
> fput_s(
> "What kind of memory usage "
> "are you envisioning for fputs?\n",
> stdout
> );
> return 0;
> }[/color]
I don't care, but it might either allocate or increase the size of a
buffer. I've recently been working with a DB wrapper layer that does
clever things which can lead to you running out of resources trying to
close a table because you have run out of resources, unless you first
close all temporary tables. So strange things can happen on running out
of resources, and that free was a cheap and easy way to reduce the
chances of something strange happening.
It was also a subtle hint to the OP that it was still allocated in case
later s/he wants to do something more intelligent on on a realloc failure.
Also, I'm happy if that is the worst thing anyone here comments on with
a piece of my code.
--
Flash Gordon
Living in interesting times.
Although my email address says spam, it is real and I read it.
pete wrote:[color=blue]
> Flash Gordon wrote:
>
>[color=green]
>> /* improve chances of the fputs not running out of memory */[/color]
>
>
> #include <stdio.h>
>
> int fput_s(const char *s, FILE *stream);
>
> int main(void)
> {
> fput_s(
> "What kind of memory usage "
> "are you envisioning for fputs?\n",
> stdout
> );
> return 0;
> }[/color]
I don't care, but it might either allocate or increase the size of a
buffer. I've recently been working with a DB wrapper layer that does
clever things which can lead to you running out of resources trying to
close a table because you have run out of resources, unless you first
close all temporary tables. So strange things can happen on running out
of resources, and that free was a cheap and easy way to reduce the
chances of something strange happening.
It was also a subtle hint to the OP that it was still allocated in case
later s/he wants to do something more intelligent on on a realloc failure.
Also, I'm happy if that is the worst thing anyone here comments on with
a piece of my code.
--
Flash Gordon
Living in interesting times.
Although my email address says spam, it is real and I read it.
Comment