Browse Source

* simdb_search_free()

master
Alex 'AdUser' Z 8 years ago
parent
commit
1ea106fa05
  1. 10
      src/database.c
  2. 10
      src/simdb.h

10
src/database.c

@ -365,6 +365,16 @@ simdb_search_init(simdb_search_t *search) {
return;
}
void
simdb_search_free(simdb_search_t *search) {
assert(search != NULL);
if (search->found == 0)
return;
FREE(search->matches);
search->found = 0;
}
int
simdb_search(simdb_t *db, simdb_search_t *search, simdb_urec_t *sample) {
simdb_match_t *matches;

10
src/simdb.h

@ -110,12 +110,18 @@ const char * simdb_error(int code);
*/
void simdb_search_init(simdb_search_t *search);
/**
* @brief Free search results
* @param search Pointer to search struct
*/
void simdb_search_free(simdb_search_t *search);
/**
* @brief Compare given record in database to other records
* @param db Database handle
* @param num Record sample number
* @param search Search parameters
* @param matches Pointer to storage for found matches (allocated)
* @note If called with non-empty search struct, results will be free()ed automatically
* @retval >0 if found some matches
* @retval 0 if nothing found
* @retval <0 on error
@ -127,7 +133,7 @@ int simdb_search_byid(simdb_t *db, simdb_search_t *search, int num);
* @param db Database handle
* @param file Path to file to compare against database
* @param search Search parameters
* @param matches Pointer to storage for found matches (allocated)
* @note If called with non-empty search struct, results will be free()ed automatically
* @retval >0 if found some matches
* @retval 0 if nothing found
* @retval <0 on error

Loading…
Cancel
Save