From: Arjen M. <arj...@de...> - 2010-12-23 13:42:42
|
Hi José, stopping the program in such dramatic circumstances may be the best option. We have had some discussion recently about the best policy, but I am what consensus was reached. I suggest right now we go ahead with your patch and see what corrections are needed later (running out of memory ought to be an unlikely event ...). Regards, Arjen On 2010-12-23 13:59, José Luis García Pallero wrote: > El día 23 de diciembre de 2010 13:41, Arjen Markus > <arj...@de...> escribió: >> Hi José, >> >> ah, well, personally I detest this type of magic, it means I >> have to remember all these little facts, but it means that >> your patch ought to be applicable as is. I will see to it. >> >> Regards, >> >> Arjen >> >> On 2010-12-23 13:39, José Luis García Pallero wrote: >>> El día 23 de diciembre de 2010 13:35, Arjen Markus >>> <arj...@de...> escribió: >>>> Hi José, >>>> >>>> at a first glance this patch (and the one for plgradient) seems okay. >>>> Only one tiny thing: I am not sure free() can be used with a NULL >>>> argument. So, I'd say you have to guard against that. (If no one >>>> picks this up, I will) >>> Hello, >>> Here: http://linux.die.net/man/3/free says >>> >>> "free(ptr) has already been called before, undefined behaviour occurs. >>> If ptr is NULL, no operation is performed. " >>> >>> I ever check the multiple malloc() returns in this way, following the >>> man page of free() >>> >>> Thanks for your time checking the patches. >>> > > I see, for example in plfill.c that other allocations looks like: > > if ( ( xint = (PLINT *) malloc( n * sizeof ( PLINT ) ) ) == NULL ) > { > plexit( "PlP_pointinpolygon: Insufficient memory" ); > } > if ( ( yint = (PLINT *) malloc( n * sizeof ( PLINT ) ) ) == NULL ) > { > plexit( "PlP_pointinpolygon: Insufficient memory" ); > } > > and > > if ( ( ( xclp = (short *) malloc( ( 2 * npts + 2 ) * sizeof ( short ) > ) ) == NULL ) || > ( ( yclp = (short *) malloc( ( 2 * npts + 2 ) * sizeof ( > short ) ) ) == NULL ) ) > { > plexit( "plP_plfclp: Insufficient memory" ); > } > > In both examples the plexit() function is used and no previous data is > freed (in the first case, if yint malloc fails, xint is not explicitly > freed). Maybe I must use plexit() instead of explicitly free. What do > you think? I don't know the internals of plexit(), but the > documentation says: > > "This routine is called in case an error is encountered during > execution of a PLplot routine. It prints the error message, tries to > release allocated resources, calls the handler provided by plsexit > and then exits." > > I don't understand exactly the meaning of "tries to release allocated > resources". Means that that it can be fails and produce memory leaks? > > Cheers. > DISCLAIMER: This message is intended exclusively for the addressee(s) and may contain confidential and privileged information. If you are not the intended recipient please notify the sender immediately and destroy this message. Unauthorized use, disclosure or copying of this message is strictly prohibited. The foundation 'Stichting Deltares', which has its seat at Delft, The Netherlands, Commercial Registration Number 41146461, is not liable in any way whatsoever for consequences and/or damages resulting from the improper, incomplete and untimely dispatch, receipt and/or content of this e-mail. |