Skip to content

Commit

Permalink
fix memory leak in tokyotyrant-test and tokyocabinet-test
Browse files Browse the repository at this point in the history
  • Loading branch information
mita committed Mar 5, 2010
1 parent 666e9e3 commit cd00b3f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
4 changes: 3 additions & 1 deletion tokyocabinet-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,10 @@ static void cursor_db(TCBDB *bdb, unsigned long count)
tcbdbcurjump2(cur, "0x");

while ((key = tcbdbcurkey2(cur)) != NULL) {
if (strncmp(key, "0x", 2) != 0)
if (strncmp(key, "0x", 2) != 0) {
free(key);
break;
}

value = tcbdbcurval2(cur);
read_value(value);
Expand Down
13 changes: 9 additions & 4 deletions tokyotyrant-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,10 @@ static void iter_db(TCRDB *rdb, unsigned long count)
}

while ((key = tcrdbiternext2(rdb)) != NULL) {
if (strncmp(key, "0x", 2) != 0)
if (strncmp(key, "0x", 2) != 0) {
free(key);
continue;
}
free(key);
}
}
Expand All @@ -162,8 +164,10 @@ static void iter_get_db(TCRDB *rdb, unsigned long count)
while ((key = tcrdbiternext2(rdb)) != NULL) {
char *value;

if (strncmp(key, "0x", 2) != 0)
if (strncmp(key, "0x", 2) != 0) {
free(key);
continue;
}

value = tcrdbget2(rdb, key);
read_value(value);
Expand All @@ -185,9 +189,10 @@ static void iter_get3_db(TCRDB *rdb, unsigned long count)
}

while ((key = tcrdbiternext2(rdb)) != NULL) {
if (strncmp(key, "0x", 2) != 0)
if (strncmp(key, "0x", 2) != 0) {
free(key);
continue;

}
tcmapput2(map, key, "");
free(key);

Expand Down

0 comments on commit cd00b3f

Please sign in to comment.