El día 23 de diciembre de 2010 13:41, Arjen Markus
<arjen.mar...@deltares.nl> 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
>> <arjen.mar...@deltares.nl> 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.

-- 
*****************************************
José Luis García Pallero
jgpall...@gmail.com
(o<
/ / \
V_/_
Use Debian GNU/Linux and enjoy!
*****************************************

------------------------------------------------------------------------------
Learn how Oracle Real Application Clusters (RAC) One Node allows customers
to consolidate database storage, standardize their database environment, and, 
should the need arise, upgrade to a full multi-node Oracle RAC database 
without downtime or disruption
http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________
Plplot-devel mailing list
Plplot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/plplot-devel

Reply via email to