Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
ccan
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
mirror
ccan
Commits
f3eecc2c
Commit
f3eecc2c
authored
Jun 10, 2014
by
Rusty Russell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
strset: use tal instead of talloc in examples and tools.
Signed-off-by:
Rusty Russell
<
rusty@rustcorp.com.au
>
parent
86502ad3
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
45 additions
and
26 deletions
+45
-26
ccan/strset/_info
ccan/strset/_info
+2
-2
ccan/strset/tools/Makefile
ccan/strset/tools/Makefile
+25
-5
ccan/strset/tools/cbspeed.c
ccan/strset/tools/cbspeed.c
+9
-10
ccan/strset/tools/speed.c
ccan/strset/tools/speed.c
+9
-9
No files found.
ccan/strset/_info
View file @
f3eecc2c
...
...
@@ -15,7 +15,7 @@
* Example:
* // Print all words in order.
* #include <ccan/strset/strset.h>
* #include <ccan/grab_file/grab_file.h>
* #include <ccan/
tal/
grab_file/grab_file.h>
* #include <err.h>
* #include <string.h>
*
...
...
@@ -31,7 +31,7 @@
* char *file, *word;
*
* strset_init(&words);
* file = grab_fd(NULL, 0
, NULL
);
* file = grab_fd(NULL, 0);
* if (!file)
* err(1, "Reading stdin");
*
...
...
ccan/strset/tools/Makefile
View file @
f3eecc2c
CFLAGS
=
-Wall
-Werror
-O3
-I
../../..
#CFLAGS=-Wall -Werror -g -I../../..
CCANDIR
=
../../..
CFLAGS
=
-Wall
-Werror
-O3
-I
$(CCANDIR)
#CFLAGS=-Wall -Werror -g -I$(CCANDIR)
all
:
cbspeed speed
cbspeed
:
cbspeed.o ../../talloc.o ../../str_talloc.o ../../grab_file.o ../../str.o ../../time.o ../../noerr
.o
CCAN_OBJS
:=
ccan-tal.o ccan-tal-str.o ccan-tal-grab_file.o ccan-take.o ccan-time.o ccan-str.o ccan-noerr.o ccan-list
.o
speed
:
speed.o ../../talloc.o ../../str_talloc.o ../../grab_file.o ../../str.o ../../time.o ../../noerr.o
cbspeed
:
cbspeed.o $(CCAN_OBJS)
speed
:
speed.o $(CCAN_OBJS)
clean
:
rm
-f
cbspeed speed speed.o cbspeed.o
rm
-f
cbspeed speed speed.o cbspeed.o
*
.o
ccan-tal.o
:
$(CCANDIR)/ccan/tal/tal.c
$(CC)
$(CFLAGS)
-c
-o
$@
$<
ccan-tal-str.o
:
$(CCANDIR)/ccan/tal/str/str.c
$(CC)
$(CFLAGS)
-c
-o
$@
$<
ccan-take.o
:
$(CCANDIR)/ccan/take/take.c
$(CC)
$(CFLAGS)
-c
-o
$@
$<
ccan-tal-grab_file.o
:
$(CCANDIR)/ccan/tal/grab_file/grab_file.c
$(CC)
$(CFLAGS)
-c
-o
$@
$<
ccan-time.o
:
$(CCANDIR)/ccan/time/time.c
$(CC)
$(CFLAGS)
-c
-o
$@
$<
ccan-list.o
:
$(CCANDIR)/ccan/list/list.c
$(CC)
$(CFLAGS)
-c
-o
$@
$<
ccan-str.o
:
$(CCANDIR)/ccan/str/str.c
$(CC)
$(CFLAGS)
-c
-o
$@
$<
ccan-noerr.o
:
$(CCANDIR)/ccan/noerr/noerr.c
$(CC)
$(CFLAGS)
-c
-o
$@
$<
ccan/strset/tools/cbspeed.c
View file @
f3eecc2c
...
...
@@ -19,9 +19,9 @@
#15: Post-Churn lookup (miss): 189-197(191)
#16: Post-Churn lookup (random): 500-531(506)
*/
#include <ccan/
str_talloc/str_talloc
.h>
#include <ccan/grab_file/grab_file.h>
#include <ccan/tal
loc/talloc
.h>
#include <ccan/
tal/str/str
.h>
#include <ccan/
tal/
grab_file/grab_file.h>
#include <ccan/tal
/tal
.h>
#include <ccan/time/time.h>
#include <stdio.h>
#include <stdlib.h>
...
...
@@ -395,23 +395,22 @@ int main(int argc, char *argv[])
critbit0_tree
ct
;
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
);
ct
.
root
=
NULL
;
num
=
tal
loc_array_length
(
words
)
-
1
;
num
=
tal
_count
(
words
)
-
1
;
printf
(
"%zu words
\n
"
,
num
);
/* Append and prepend last char for miss testing. */
misswords
=
tal
loc_array
(
words
,
char
*
,
num
);
misswords
=
tal
_arr
(
words
,
char
*
,
num
);
for
(
i
=
0
;
i
<
num
;
i
++
)
{
char
lastc
;
if
(
strlen
(
words
[
i
]))
lastc
=
words
[
i
][
strlen
(
words
[
i
])
-
1
];
else
lastc
=
'z'
;
misswords
[
i
]
=
tal
loc_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: "
);
...
...
ccan/strset/tools/speed.c
View file @
f3eecc2c
...
...
@@ -19,8 +19,8 @@
#15: Post-Churn lookup (miss): 175-186(176)
#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/time/time.h>
#include <ccan/strset/strset.c>
...
...
@@ -46,23 +46,23 @@ int main(int argc, char *argv[])
struct
strset
set
;
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
);
num
=
tal
loc_array_length
(
words
)
-
1
;
num
=
tal
_count
(
words
)
-
1
;
printf
(
"%zu words
\n
"
,
num
);
/* Append and prepend last char for miss testing. */
misswords
=
tal
loc_array
(
words
,
char
*
,
num
);
misswords
=
tal
_arr
(
words
,
char
*
,
num
);
for
(
i
=
0
;
i
<
num
;
i
++
)
{
char
lastc
;
if
(
strlen
(
words
[
i
]))
lastc
=
words
[
i
][
strlen
(
words
[
i
])
-
1
];
else
lastc
=
'z'
;
misswords
[
i
]
=
tal
loc_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: "
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment