Skip to content

Commit 43231cd

Browse files
starseekercshorler
authored andcommitted
Set default types, note a bad problem with how sc_hash is set up.
1 parent 7209a3e commit 43231cd

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

src/clutils/sc_hash.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ void * SC_HASHfind( Hash_TableP t, char * s ) {
5050

5151
e.key = s;
5252
e.symbol = 0; /* initialize to 0 - 25-Apr-1994 - kcm */
53+
e.type = '*';
5354
ep = SC_HASHsearch( t, &e, HASH_FIND );
5455
return( ep ? ep->data : 0 );
5556
}
@@ -61,6 +62,7 @@ void SC_HASHinsert( Hash_TableP t, char * s, void * data ) {
6162
e.key = s;
6263
e.data = data;
6364
e.symbol = 0;
65+
e.type = '*';
6466
e2 = SC_HASHsearch( t, &e, HASH_INSERT );
6567
if( e2 ) {
6668
fprintf( stderr, "%s: Redeclaration of %s\n", __func__, s );
@@ -258,6 +260,9 @@ struct Element * SC_HASHsearch( Hash_TableP table, const struct Element * item,
258260
/*STRINGfree(deleteme->key);*/
259261
SC_HASH_Element_destroy( deleteme );
260262
--table->KeyCount;
263+
// TODO - we shouldn't be returning this pointer - it invites a
264+
// USE_AFTER_FREE error. Could we just replace SC_HASH completely
265+
// with one of the C++ containers?
261266
return( deleteme ); /* of course, user shouldn't deref this! */
262267
case HASH_INSERT:
263268
/* if trying to insert it (twice), let them know */

0 commit comments

Comments
 (0)