[Monetdb-developers] [Monetdb-sql-checkins] sql/src/storage/bpm bpm_distribution.mx, , 1.1, 1.2

Romulo Goncalves R.A.Goncalves at cwi.nl
Tue Jul 22 10:57:18 CEST 2008


Stefan Manegold wrote:
> On Tue, Jul 22, 2008 at 09:58:07AM +0200, Romulo Goncalves wrote:
>> Stefan Manegold wrote:
>>> On Mon, Jul 21, 2008 at 04:08:53PM +0000, Romulo Goncalves wrote:
>>>> Update of /cvsroot/monetdb/sql/src/storage/bpm
>>>> In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv12270
>>>>
>>>> Modified Files:
>>>> 	bpm_distribution.mx 
>>>> Log Message:
>>>> Use strdup to avoid problems with garbage on the string.
>>>>
>>> I suppose you do take care of the "garbage" that strdup() creates,
>>> i.e., free() the malloc()'ed memory once it is not used any more ...
>> The _DELETE functions is used when a bpmHost is destroyed.
>> Does it free the memory?
> 
> I don't know the _DELETE functions --- simply look at them ...
I just used an example where the procedures to create and destroy a 
structure are the same as mine.

I checked in this change because the strings were not stored in the 
structure.

After the function call the strings used to to create the structure were 
destroyed because they were local variables.

Using the strdup I create a copy of them which is them destroyed when 
the structure is destroyed, using the _DELETE function.

The destroy function was implemented correctly, but it was not the case 
for the create function.

Niels, check if I miss something....


Romulo


> 
> I just noticed that your checkin creates one extra copy of each of these
> strings, but I did not see any extra delete (free) calls; hence, (even) if
> the original code did free the original strings (e.g., via the _DELETE
> functions), it will not free your new copies, instead, but leave the
> original strings behind creating leaks ...
> 
> Stefan
> 
>> Romulo
>>> Stefan
>>>
>>>> U bpm_distribution.mx
>>>> Index: bpm_distribution.mx
>>>> ===================================================================
>>>> RCS file: /cvsroot/monetdb/sql/src/storage/bpm/bpm_distribution.mx,v
>>>> retrieving revision 1.1
>>>> retrieving revision 1.2
>>>> diff -u -d -r1.1 -r1.2
>>>> --- bpm_distribution.mx	19 Jan 2008 17:10:34 -0000	1.1
>>>> +++ bpm_distribution.mx	21 Jul 2008 16:08:50 -0000	1.2
>>>> @@ -90,11 +90,11 @@
>>>>  	bpmHost bpmH = NULL;
>>>>  	bpmH = ZNEW(bpmHostRec);
>>>>  	bpmH->id = id;
>>>> -	bpmH->host = host;
>>>> +	bpmH->host = strdup(host);
>>>>  	bpmH->port = port;
>>>> -	bpmH->dbname = dbname;
>>>> -	bpmH->user = user;
>>>> -	bpmH->passwd = password;
>>>> +	bpmH->dbname = strdup(dbname);
>>>> +	bpmH->user = strdup(user);
>>>> +	bpmH->passwd = strdup(password);
>>>>  	bpmH->next = hostAnchor;
>>>>  	hostAnchor = bpmH;
>>>>  
>>>>
>>>>
>>>> -------------------------------------------------------------------------
>>>> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
>>>> Build the coolest Linux based applications with Moblin SDK & win great prizes
>>>> Grand prize is a trip for two to an Open Source event anywhere in the world
>>>> http://moblin-contest.org/redirect.php?banner_id=100&url=/
>>>> _______________________________________________
>>>> Monetdb-sql-checkins mailing list
>>>> Monetdb-sql-checkins at lists.sourceforge.net
>>>> https://lists.sourceforge.net/lists/listinfo/monetdb-sql-checkins
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>
>> -------------------------------------------------------------------------
>> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
>> Build the coolest Linux based applications with Moblin SDK & win great prizes
>> Grand prize is a trip for two to an Open Source event anywhere in the world
>> http://moblin-contest.org/redirect.php?banner_id=100&url=/
>> _______________________________________________
>> Monetdb-developers mailing list
>> Monetdb-developers at lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/monetdb-developers
>>
> 





More information about the developers-list mailing list