[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Purify'ing my bison. Desperate for HELP! PLEASE!!!
From: |
Billy Patton |
Subject: |
Purify'ing my bison. Desperate for HELP! PLEASE!!! |
Date: |
Fri, 25 Jan 2002 08:50:27 -0600 |
I've got a yacc that I'm getting complaints about form Purify.
This is on a Sun Solaris 7 UNix box.
I have something this:
object_tag : OBJECT qstring
{
char *name = my_string_storage(NULL,$2);
cell_p cell = cell_malloc(NULL);
#ifdef LAFF_YACC_PRINT
printf("line# : %d : object_tag
'%s'\n",linenum,name);
#endif
$$ = node_malloc(lOBJECT,name);
if(current_lib[0] NE '\0') {
node_t *np = node_malloc(lLIB,current_lib);
np->child = $$;
cell->head = np;
}
else {
cell->head = $$;
}
cell->name = name;
if (! add_cell_pointer(db,cell))
{
lERROR;
printf("add_cell_pointer : failed to add cell
\"%s\""
" in ReadLaff\n",name);
YYERROR;
}
}
object_data ')'
{
$$ = $<nptr>3;
}
;
object_data : /* optional */
{ $$ = NULL }
| '(' ')'
{ $$ = NULL; }
| '(' object_children ')'
{ $$ = $2; }
;
object_children : object_child
{
yyvsp[-2].nptr->child = $1;
$1->parent = yyvsp[-2].nptr;
}
| object_children object_child
{
$1->sibling = $2;
$2->parent = yyvsp[-3].nptr;
$$ = $2;
}
;
object_child : attr_tag
;
attr_tag : ATTR qstring
{
#ifdef LAFF_YACC_PRINT
printf("line# : %d : attr_tag '%s'\n",linenum,$2);
#endif
$$ = node_malloc(lATTR,$2);
}
attr_data ')'
{
$$ = $<nptr>3;
}
;
attr_data : /* optional */
{ $$ = NULL; }
| '(' attr_children ')'
{ $$ = $2; }
;
attr_children : attr_child
{
yyvsp[-2].nptr->child = $1;
$1->parent = yyvsp[-2].nptr;
}
| attr_children attr_child
{
$1->sibling = $2;
$2->parent = yyvsp[-3].nptr;
$$ = $2;
}
;
attr_child : text_tag
;
text_tag : TEXT qstring
{
#ifdef LAFF_YACC_PRINT
printf("line# : %d : text_tag %s\n",linenum,$2);
#endif
$$ = node_malloc(lTEXT,$2);
}
text_data ')'
{
$$ = $<nptr>3;
}
;
text_data : /* optional */
{ $$ = NULL; }
| '(' text_children ')'
{ $$ = $2; }
;
text_children : geometric_tag
{
yyvsp[-2].nptr->child = $1;
$1->parent = yyvsp[-2].nptr;
}
| text_children geometric_tag
{
$1->sibling = $2;
$2->parent = yyvsp[-3].nptr;
$$ = $2;
}
;
HERE IS MY DATA:
;LAFF
(OBJECT 'BARINFO' (
(ATTR 'UNITS' (
(TEXT '0.001 MICRONS')))
(ATTR 'LAYERS' (
(TEXT ' 1 1 1 1 1 MET1')))))
Notice I ahve 5 places where memory is allocated.
OBJECT, 2 ATTR's and 2 TEXT
A link list is built from this grammer.
I can build the list manually to test my free routine.
Purify complains of no problems. But when I run the data
through this yacc I get memory leask from the cell_malloc
and
MLK: 16040 bytes leaked at 0x154008
* This memory was allocated from:
malloc [rtlib.o]
cell_malloc [cell.c:24]
yylaffparse [laff.y:202] ->object_tag
laff_read [laff_db.c:348]
t_cell_smash [TEST.c:2549]
main [TEST.c:3013]
MLK: 40 bytes leaked in 2 blocks
* This memory was allocated from:
malloc [rtlib.o]
node_malloc [node.c:18]
yylaffparse [laff.y:820] ->attr_tag
laff_read [laff_db.c:348]
t_cell_smash [TEST.c:2549]
main [TEST.c:3013]
* Block of 20 bytes (2 times); last block at 0x158230
MLK: 40 bytes leaked in 2 blocks
* This memory was allocated from:
malloc [rtlib.o]
node_malloc [node.c:18]
yylaffparse [laff.y:784] -> text_tag
laff_read [laff_db.c:348]
t_cell_smash [TEST.c:2549]
main [TEST.c:3013]
* Block of 20 bytes (2 times); last block at 0x158358
MLK: 20 bytes leaked at 0x157f08
* This memory was allocated from:
malloc [rtlib.o]
node_malloc [node.c:18]
yylaffparse [laff.y:206] -> object_tag
laff_read [laff_db.c:348]
t_cell_smash [TEST.c:2549]
main [TEST.c:3013]
I noticed that as each $$=.. in the *.tab.c that
yyval.nptr is assigned a value.
It almost looks like $$ is duplicated when it
is returned and not free'd.
I'm sure the problem is in my code, but I just can't
see it.
CAN SOMEONE PLEASE HELP
dragon 60 % bison --version
GNU Bison version 1.25
dragon 62 % uname -a
SunOS dragon 5.7 Generic_106541-14 sun4u sparc SUNW,Ultra-5_10
dragon 63 % gcc -v
Reading specs from
/usr/local/lib/gcc-lib/sparc-sun-solaris2.7/2.8.1/specs
gcc version 2.8.1
- Purify'ing my bison. Desperate for HELP! PLEASE!!!,
Billy Patton <=