@@ -23,7 +23,7 @@ void GInstall(char *name, struct Typetable *type, int size, struct Paramstruct *
23
23
}
24
24
25
25
temp = (struct Gsymbol * )malloc (sizeof (struct Gsymbol ));
26
- temp -> name = (char * )malloc (sizeof (name ));
26
+ temp -> name = (char * )malloc (strlen (name ) * sizeof ( char ));
27
27
strcpy (temp -> name , name );
28
28
temp -> type = type ;
29
29
temp -> size = size ;
@@ -67,7 +67,7 @@ void LInstall(char *name, struct Typetable *type)
67
67
{
68
68
struct Lsymbol * temp ;
69
69
temp = (struct Lsymbol * )malloc (sizeof (struct Lsymbol ));
70
- temp -> name = (char * )malloc (sizeof (name ));
70
+ temp -> name = (char * )malloc (strlen (name ) * sizeof ( char ));
71
71
strcpy (temp -> name , name );
72
72
temp -> type = type ;
73
73
temp -> next = NULL ;
@@ -100,7 +100,7 @@ void PInstall(char *name, struct Typetable *type)
100
100
{
101
101
struct Paramstruct * temp ;
102
102
temp = (struct Paramstruct * )malloc (sizeof (struct Paramstruct ));
103
- temp -> name = (char * )malloc (sizeof (name ));
103
+ temp -> name = (char * )malloc (strlen (name ) * sizeof ( char ));
104
104
strcpy (temp -> name , name );
105
105
temp -> type = type ;
106
106
temp -> next = NULL ;
@@ -135,7 +135,7 @@ void TInstall(char *name, int size, struct Fieldlist *fields)
135
135
int counter = 0 ;
136
136
137
137
temp = (struct Typetable * )malloc (sizeof (struct Typetable ));
138
- temp -> name = (char * )malloc (sizeof (name ));
138
+ temp -> name = (char * )malloc (strlen (name ) * sizeof ( char ));
139
139
strcpy (temp -> name , name );
140
140
temp -> next = NULL ;
141
141
@@ -183,7 +183,7 @@ void FInstall(struct Typetable *type, char *name)
183
183
struct Fieldlist * temp ;
184
184
struct Typetable * temp1 ;
185
185
temp = (struct Fieldlist * )malloc (sizeof (struct Fieldlist ));
186
- temp -> name = (char * )malloc (sizeof (name ));
186
+ temp -> name = (char * )malloc (strlen (name ) * sizeof ( char ));
187
187
strcpy (temp -> name , name );
188
188
temp -> type = type ;
189
189
temp -> next = NULL ;
@@ -210,4 +210,4 @@ void printSymbolTable()
210
210
printf ("%s----%s-----%d\n" , temp -> name , temp -> type -> name , temp -> binding );
211
211
temp = temp -> next ;
212
212
}
213
- }
213
+ }
0 commit comments