mirror of
https://github.com/nfc-tools/mfcuk.git
synced 2026-03-14 11:33:49 +00:00
Use fclose at right time, count the loaded fingerpriting files (Fixes Issue 5)
This commit is contained in:
@@ -146,6 +146,7 @@ int mfcuk_finger_load()
|
|||||||
size_t result = 0;
|
size_t result = 0;
|
||||||
mfcuk_finger_template *tmpl_new = NULL;
|
mfcuk_finger_template *tmpl_new = NULL;
|
||||||
|
|
||||||
|
int template_loaded_count = 0;
|
||||||
for (i = 0; i<mfcuk_finger_db_entries; i++)
|
for (i = 0; i<mfcuk_finger_db_entries; i++)
|
||||||
{
|
{
|
||||||
fp = fopen(mfcuk_finger_db[i].tmpl_filename, "rb");
|
fp = fopen(mfcuk_finger_db[i].tmpl_filename, "rb");
|
||||||
@@ -171,13 +172,13 @@ int mfcuk_finger_load()
|
|||||||
fclose(fp);
|
fclose(fp);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
fclose(fp);
|
||||||
|
|
||||||
if (mfcuk_finger_db[i].tmpl_data == NULL)
|
if (mfcuk_finger_db[i].tmpl_data == NULL)
|
||||||
{
|
{
|
||||||
if ( (tmpl_new = (mfcuk_finger_template *) malloc(sizeof(mfcuk_finger_template))) == 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);
|
fprintf(stderr, "WARN: cannot allocate memory to template record %d\n", i);
|
||||||
fclose(fp);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -185,12 +186,12 @@ int mfcuk_finger_load()
|
|||||||
memcpy( &(tmpl_new->values), &(values), sizeof(values));
|
memcpy( &(tmpl_new->values), &(values), sizeof(values));
|
||||||
|
|
||||||
mfcuk_finger_db[i].tmpl_data = tmpl_new;
|
mfcuk_finger_db[i].tmpl_data = tmpl_new;
|
||||||
|
template_loaded_count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose(fp);
|
|
||||||
|
|
||||||
return 1;
|
return template_loaded_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
int mfcuk_finger_unload()
|
int mfcuk_finger_unload()
|
||||||
|
|||||||
Reference in New Issue
Block a user