|
@@ -19,8 +19,8 @@
|
|
|
#15: Post-Churn lookup (miss): 175-186(176)
|
|
#15: Post-Churn lookup (miss): 175-186(176)
|
|
|
#16: Post-Churn lookup (random): 522-534(525)
|
|
#16: Post-Churn lookup (random): 522-534(525)
|
|
|
*/
|
|
*/
|
|
|
-#include <ccan/str_talloc/str_talloc.h>
|
|
|
|
|
-#include <ccan/grab_file/grab_file.h>
|
|
|
|
|
|
|
+#include <ccan/tal/str/str.h>
|
|
|
|
|
+#include <ccan/tal/grab_file/grab_file.h>
|
|
|
#include <ccan/talloc/talloc.h>
|
|
#include <ccan/talloc/talloc.h>
|
|
|
#include <ccan/time/time.h>
|
|
#include <ccan/time/time.h>
|
|
|
#include <ccan/strset/strset.c>
|
|
#include <ccan/strset/strset.c>
|
|
@@ -46,23 +46,23 @@ int main(int argc, char *argv[])
|
|
|
struct strset set;
|
|
struct strset set;
|
|
|
char **words, **misswords;
|
|
char **words, **misswords;
|
|
|
|
|
|
|
|
- words = strsplit(NULL, grab_file(NULL,
|
|
|
|
|
- argv[1] ? argv[1] : "/usr/share/dict/words",
|
|
|
|
|
- NULL), "\n");
|
|
|
|
|
|
|
+ words = tal_strsplit(NULL, grab_file(NULL,
|
|
|
|
|
+ argv[1] ? argv[1] : "/usr/share/dict/words"),
|
|
|
|
|
+ "\n", STR_NO_EMPTY);
|
|
|
strset_init(&set);
|
|
strset_init(&set);
|
|
|
- num = talloc_array_length(words) - 1;
|
|
|
|
|
|
|
+ num = tal_count(words) - 1;
|
|
|
printf("%zu words\n", num);
|
|
printf("%zu words\n", num);
|
|
|
|
|
|
|
|
/* Append and prepend last char for miss testing. */
|
|
/* Append and prepend last char for miss testing. */
|
|
|
- misswords = talloc_array(words, char *, num);
|
|
|
|
|
|
|
+ misswords = tal_arr(words, char *, num);
|
|
|
for (i = 0; i < num; i++) {
|
|
for (i = 0; i < num; i++) {
|
|
|
char lastc;
|
|
char lastc;
|
|
|
if (strlen(words[i]))
|
|
if (strlen(words[i]))
|
|
|
lastc = words[i][strlen(words[i])-1];
|
|
lastc = words[i][strlen(words[i])-1];
|
|
|
else
|
|
else
|
|
|
lastc = 'z';
|
|
lastc = 'z';
|
|
|
- misswords[i] = talloc_asprintf(misswords, "%c%s%c%c",
|
|
|
|
|
- lastc, words[i], lastc, lastc);
|
|
|
|
|
|
|
+ misswords[i] = tal_fmt(misswords, "%c%s%c%c",
|
|
|
|
|
+ lastc, words[i], lastc, lastc);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
printf("#01: Initial insert: ");
|
|
printf("#01: Initial insert: ");
|