Re: [ng-spice] History and command completion


To ng-spice@ieee.ing.uniroma1.it
From "GLAO S. Dezai" <dezai@hotbot.com>
Date Wed, 08 Nov 2000 07:31:10 -0800
Delivered-To mailing list ng-spice@ieee.ing.uniroma1.it
Mailing-List contact ng-spice-help@ieee.ing.uniroma1.it; run by ezmlm
Organization HotBot Mail (http://mail.hotbot.mailcity.lycos.com:80)
Reply-To ng-spice@ieee.ing.uniroma1.it

 
>Question for all:
>    Who have been changing variable.c ? This version causes immediate core
>dumps on startup. Looked at it this morning and I see typical bugs there,
>like:
>    copyval = cp_unquote(val);
>    strcpy(val, copyval);
>    txfree(copyval);
>

Yes i did. And it worked on my system without any segfault or anything else. 
But The problem is that i didnt see that the Berkeley original tmalloc code 
has been removed in ngspice using calloc instead of malloc. That is (i think) 
why txfree do not work.
The cp_unquote function allocate memory by the copy function each time it is 
called. In many cases the allocated memory is not released.
My patches looks like what is already present in ft_xgraph function
...
if(title) {
  text=cp_unquote(title);
  ...
  tfree(text);
  ...



>Good, memory leak seems to be fixed, but cp_unquote() does not return malloc
>pointer, and then txfree() fails. Anyway this should be done more optimal
>like:
>    copyval = val;
>    val = cp_unquote(val);
>    txfree(copyval);
>

I dont agree, because we cannot free val since we dont know where it has been 
allocated. We free the result of the cp_unquote after use because we know 
that the string has been copied and must be freed to avoid the memory leak 
problem.

Anyway, i am sorry because i didnot test it directly on ngspice.

Paolo, is it possible to remove the patch until a solution is found to free 
safely the memory?

Dezai Glao







HotBot - Search smarter.
http://www.hotbot.com

Partial thread listing: