Skip to content

Commit

Permalink
Use fclose at right time, count the loaded fingerpriting files (Fixes…
Browse files Browse the repository at this point in the history
… Issue 5)
  • Loading branch information
[email protected] committed Sep 25, 2011
1 parent de55e33 commit 756b48d
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/mfcuk_finger.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,8 @@ int mfcuk_finger_load()
FILE *fp = NULL;
size_t result = 0;
mfcuk_finger_template *tmpl_new = NULL;


int template_loaded_count = 0;
for (i = 0; i<mfcuk_finger_db_entries; i++)
{
fp = fopen(mfcuk_finger_db[i].tmpl_filename, "rb");
Expand All @@ -171,26 +172,26 @@ int mfcuk_finger_load()
fclose(fp);
continue;
}
fclose(fp);

if (mfcuk_finger_db[i].tmpl_data == NULL)
{
if ( (tmpl_new = (mfcuk_finger_template *) malloc(sizeof(mfcuk_finger_template))) == NULL)
{
fprintf(stderr, "WARN: cannot allocate memory to template record %d\n", i);
fclose(fp);
continue;
}

memcpy( &(tmpl_new->mask), &(mask), sizeof(mask));
memcpy( &(tmpl_new->values), &(values), sizeof(values));

mfcuk_finger_db[i].tmpl_data = tmpl_new;
template_loaded_count++;
}
}

fclose(fp);

return 1;
return template_loaded_count;
}

int mfcuk_finger_unload()
Expand Down

0 comments on commit 756b48d

Please sign in to comment.