diff options
author | Donald Sharp <sharpd@cumulusnetworks.com> | 2020-03-22 03:56:03 +0100 |
---|---|---|
committer | Donald Sharp <sharpd@cumulusnetworks.com> | 2020-03-24 12:33:13 +0100 |
commit | 1a4189d4a1d2170f2fc3929b4e422e9c3b75a60a (patch) | |
tree | 62807bdcfbe5c8ee681fdeb623b5fe02aeab414e /lib | |
parent | bgpd: Make bgp_debug_bestpath take a `struct bgp_node` (diff) | |
download | frr-1a4189d4a1d2170f2fc3929b4e422e9c3b75a60a.tar.xz frr-1a4189d4a1d2170f2fc3929b4e422e9c3b75a60a.zip |
bgpd, isisd, lib: Make key values const for skiplist
Make some key values const for the skiplist code.
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/skiplist.c | 11 | ||||
-rw-r--r-- | lib/skiplist.h | 13 |
2 files changed, 13 insertions, 11 deletions
diff --git a/lib/skiplist.c b/lib/skiplist.c index d955c6eb9..fa25770ef 100644 --- a/lib/skiplist.c +++ b/lib/skiplist.c @@ -112,7 +112,7 @@ static int randomLevel(void) return level; } -static int default_cmp(void *key1, void *key2) +static int default_cmp(const void *key1, const void *key2) { if (key1 < key2) return -1; @@ -126,7 +126,8 @@ unsigned int skiplist_count(struct skiplist *l) return l->count; } -struct skiplist *skiplist_new(int flags, int (*cmp)(void *key1, void *key2), +struct skiplist *skiplist_new(int flags, + int (*cmp)(const void *key1, const void *key2), void (*del)(void *val)) { struct skiplist *new; @@ -329,8 +330,8 @@ int skiplist_delete(register struct skiplist *l, register void *key, * Also set a cursor for use with skiplist_next_value. */ int skiplist_first_value(register struct skiplist *l, /* in */ - register void *key, /* in */ - void **valuePointer, /* out */ + register const void *key, /* in */ + void **valuePointer, /* out */ void **cursor) /* out */ { register int k; @@ -374,7 +375,7 @@ int skiplist_search(register struct skiplist *l, register void *key, * last element with the given key, -1 is returned. */ int skiplist_next_value(register struct skiplist *l, /* in */ - register void *key, /* in */ + register const void *key, /* in */ void **valuePointer, /* in/out */ void **cursor) /* in/out */ { diff --git a/lib/skiplist.h b/lib/skiplist.h index 2ab37331c..a106a455d 100644 --- a/lib/skiplist.h +++ b/lib/skiplist.h @@ -68,7 +68,7 @@ struct skiplist { * Returns -1 if val1 < val2, 0 if equal?, 1 if val1 > val2. * Used as definition of sorted for listnode_add_sort */ - int (*cmp)(void *val1, void *val2); + int (*cmp)(const void *val1, const void *val2); /* callback to free user-owned data when listnode is deleted. supplying * this callback is very much encouraged! @@ -81,8 +81,9 @@ struct skiplist { extern struct skiplist * skiplist_new(/* encouraged: set list.del callback on new lists */ int flags, - int (*cmp)(void *key1, void *key2), /* NULL => default cmp */ - void (*del)(void *val)); /* NULL => no auto val free */ + int (*cmp)(const void *key1, + const void *key2), /* NULL => default cmp */ + void (*del)(void *val)); /* NULL => no auto val free */ extern void skiplist_free(struct skiplist *); @@ -96,12 +97,12 @@ extern int skiplist_search(register struct skiplist *l, register void *key, void **valuePointer); extern int skiplist_first_value(register struct skiplist *l, /* in */ - register void *key, /* in */ - void **valuePointer, /* in/out */ + register const void *key, /* in */ + void **valuePointer, /* in/out */ void **cursor); /* out */ extern int skiplist_next_value(register struct skiplist *l, /* in */ - register void *key, /* in */ + register const void *key, /* in */ void **valuePointer, /* in/out */ void **cursor); /* in/out */ |