Use fclose at right time, count the loaded fingerpriting files (Fixes Issue 5)

This commit is contained in:
rconty@il4p.fr 2011-09-25 17:07:59 +00:00
parent de55e33177
commit 756b48d7d9

View File

@ -146,6 +146,7 @@ int mfcuk_finger_load()
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");
@ -171,13 +172,13 @@ 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;
}
@ -185,12 +186,12 @@ int mfcuk_finger_load()
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()