Browse Source

* rename type : match_t -> imdb_match_t

master
Alex 'AdUser' Z 9 years ago
parent
commit
4b4a90fbb7
  1. 6
      src/database.c
  2. 4
      src/database.h
  3. 2
      src/util.c

6
src/database.c

@ -192,7 +192,7 @@ int imdb_write_list(imdb_t *db, imdb_rec_t *list, size_t list_len)
return processed;
}
int imdb_search(imdb_t *db, imdb_rec_t *sample, float tresh, match_t **matches)
int imdb_search(imdb_t *db, imdb_rec_t *sample, float tresh, imdb_match_t **matches)
{
const int blk_size = 4096;
uint64_t found = 0;
@ -233,13 +233,13 @@ int imdb_search(imdb_t *db, imdb_rec_t *sample, float tresh, match_t **matches)
/* allocate more memory, if needed */
if (found % 10 == 0) {
*matches = realloc(*matches, (found + 10) * sizeof(match_t));
*matches = realloc(*matches, (found + 10) * sizeof(imdb_match_t));
if (*matches == NULL) {
db->errstr = "Memory allocation error";
FREE(blk.data);
return -1;
}
memset(&(*matches)[found], 0x0, sizeof(match_t) * 10);
memset(&(*matches)[found], 0x0, sizeof(imdb_match_t) * 10);
}
/* create match record */

4
src/database.h

@ -66,7 +66,7 @@ typedef struct {
typedef struct {
uint64_t num;
float diff;
} match_t;
} imdb_match_t;
extern int imdb_open (imdb_t *db, const char *path);
extern int imdb_close(imdb_t *db);
@ -86,6 +86,6 @@ extern int imdb_write_list(imdb_t *db, imdb_rec_t *list, size_t list_len);
0 if nothing found
>0 if found some matches
*/
extern int imdb_search(imdb_t *db, imdb_rec_t *sample, float tresh, match_t **matches);
extern int imdb_search(imdb_t *db, imdb_rec_t *sample, float tresh, imdb_match_t **matches);
#endif

2
src/util.c

@ -43,7 +43,7 @@ void usage(int exitcode) {
int search_similar(imdb_t *db, imdb_rec_t *sample, float tresh)
{
int ret = 0, i = 0;
match_t *matches = NULL;
imdb_match_t *matches = NULL;
ret = imdb_search(db, sample, tresh, &matches);
if (ret == -1) {

Loading…
Cancel
Save