Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
RIOT
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cm-projects
RIOT
Commits
88ae531e
Commit
88ae531e
authored
10 years ago
by
Christian Mehlis
Browse files
Options
Downloads
Plain Diff
Merge pull request #1679 from cgundogan/bloom_t_as_typedef
sys: use typedef for `struct bloom_t`
parents
28307688
0a4ea07d
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
sys/bloom/bloom.c
+6
-6
6 additions, 6 deletions
sys/bloom/bloom.c
sys/include/bloom.h
+7
-7
7 additions, 7 deletions
sys/include/bloom.h
tests/bloom/main.c
+1
-1
1 addition, 1 deletion
tests/bloom/main.c
tests/bloom_bytes/main.c
+1
-1
1 addition, 1 deletion
tests/bloom_bytes/main.c
with
15 additions
and
15 deletions
sys/bloom/bloom.c
+
6
−
6
View file @
88ae531e
...
...
@@ -23,14 +23,14 @@
#define GETBIT(a,n) (a[n/CHAR_BIT] & (1<<(n%CHAR_BIT)))
#define ROUND(size) ((size + CHAR_BIT - 1) / CHAR_BIT)
struct
bloom_t
*
bloom_new
(
size_t
size
,
size_t
num_hashes
,
...)
bloom_t
*
bloom_new
(
size_t
size
,
size_t
num_hashes
,
...)
{
struct
bloom_t
*
bloom
;
bloom_t
*
bloom
;
va_list
hashes
;
size_t
n
;
/* Allocate Bloom filter container */
if
(
!
(
bloom
=
malloc
(
sizeof
(
struct
bloom_t
))))
{
if
(
!
(
bloom
=
malloc
(
sizeof
(
bloom_t
))))
{
return
NULL
;
}
...
...
@@ -66,14 +66,14 @@ struct bloom_t *bloom_new(size_t size, size_t num_hashes, ...)
return
bloom
;
}
void
bloom_del
(
struct
bloom_t
*
bloom
)
void
bloom_del
(
bloom_t
*
bloom
)
{
free
(
bloom
->
a
);
free
(
bloom
->
hash
);
free
(
bloom
);
}
void
bloom_add
(
struct
bloom_t
*
bloom
,
const
uint8_t
*
buf
,
size_t
len
)
void
bloom_add
(
bloom_t
*
bloom
,
const
uint8_t
*
buf
,
size_t
len
)
{
for
(
size_t
n
=
0
;
n
<
bloom
->
k
;
n
++
)
{
uint32_t
hash
=
bloom
->
hash
[
n
](
buf
,
len
);
...
...
@@ -81,7 +81,7 @@ void bloom_add(struct bloom_t *bloom, const uint8_t *buf, size_t len)
}
}
bool
bloom_check
(
struct
bloom_t
*
bloom
,
const
uint8_t
*
buf
,
size_t
len
)
bool
bloom_check
(
bloom_t
*
bloom
,
const
uint8_t
*
buf
,
size_t
len
)
{
for
(
size_t
n
=
0
;
n
<
bloom
->
k
;
n
++
)
{
uint32_t
hash
=
bloom
->
hash
[
n
](
buf
,
len
);
...
...
This diff is collapsed.
Click to expand it.
sys/include/bloom.h
+
7
−
7
View file @
88ae531e
...
...
@@ -133,14 +133,14 @@
typedef
uint32_t
(
*
hashfp_t
)(
const
uint8_t
*
,
int
len
);
/**
*
struct
bloom_t bloom filter object
* bloom_t bloom filter object
*/
struct
bloom_
t
{
typedef
struc
t
{
size_t
m
;
size_t
k
;
uint8_t
*
a
;
hashfp_t
*
hash
;
};
}
bloom_t
;
/**
* bloom_new Allocate and return a pointer to a new Bloom filter.
...
...
@@ -154,7 +154,7 @@ struct bloom_t {
* @return An allocated bloom filter
*
*/
struct
bloom_t
*
bloom_new
(
size_t
size
,
size_t
num_hashes
,
...);
bloom_t
*
bloom_new
(
size_t
size
,
size_t
num_hashes
,
...);
/**
* bloom_del Delete a Bloom filter.
...
...
@@ -163,7 +163,7 @@ struct bloom_t *bloom_new(size_t size, size_t num_hashes, ...);
* @return nothing
*
*/
void
bloom_del
(
struct
bloom_t
*
bloom
);
void
bloom_del
(
bloom_t
*
bloom
);
/**
* bloom_add Add a string to a Bloom filter.
...
...
@@ -176,7 +176,7 @@ void bloom_del(struct bloom_t *bloom);
* @return nothing
*
*/
void
bloom_add
(
struct
bloom_t
*
bloom
,
const
uint8_t
*
buf
,
size_t
len
);
void
bloom_add
(
bloom_t
*
bloom
,
const
uint8_t
*
buf
,
size_t
len
);
/**
* bloom_check Determine if a string is in the Bloom filter.
...
...
@@ -213,7 +213,7 @@ void bloom_add(struct bloom_t *bloom, const uint8_t *buf, size_t len);
* @return true if string is may be in the filter
*
*/
bool
bloom_check
(
struct
bloom_t
*
bloom
,
const
uint8_t
*
buf
,
size_t
len
);
bool
bloom_check
(
bloom_t
*
bloom
,
const
uint8_t
*
buf
,
size_t
len
);
/** @} */
#endif
/* _BLOOM_FILTER_H */
This diff is collapsed.
Click to expand it.
tests/bloom/main.c
+
1
−
1
View file @
88ae531e
...
...
@@ -28,7 +28,7 @@
int
main
(
void
)
{
struct
bloom_t
*
bloom
=
bloom_new
(
1
<<
7
,
6
,
fnv_hash
,
sax_hash
,
sdbm_hash
,
bloom_t
*
bloom
=
bloom_new
(
1
<<
7
,
6
,
fnv_hash
,
sax_hash
,
sdbm_hash
,
djb2_hash
,
kr_hash
,
dek_hash
,
rotating_hash
,
one_at_a_time_hash
);
printf
(
"Testing Bloom filter.
\n\n
"
);
...
...
This diff is collapsed.
Click to expand it.
tests/bloom_bytes/main.c
+
1
−
1
View file @
88ae531e
...
...
@@ -50,7 +50,7 @@ int main(void)
{
hwtimer_init
();
struct
bloom_t
*
bloom
=
bloom_new
(
1
<<
12
,
8
,
fnv_hash
,
sax_hash
,
sdbm_hash
,
bloom_t
*
bloom
=
bloom_new
(
1
<<
12
,
8
,
fnv_hash
,
sax_hash
,
sdbm_hash
,
djb2_hash
,
kr_hash
,
dek_hash
,
rotating_hash
,
one_at_a_time_hash
);
printf
(
"Testing Bloom filter.
\n\n
"
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment