summaryrefslogtreecommitdiff
path: root/lib/srv6.h
diff options
context:
space:
mode:
authorCarmine Scarpitta <carmine.scarpitta@uniroma2.it>2022-10-29 17:04:35 +0200
committerCarmine Scarpitta <carmine.scarpitta@uniroma2.it>2022-10-29 17:04:35 +0200
commit6946731314fd04c499e576d0e133879f3e9c2edd (patch)
tree42d1cd47714e42cca90ef6fabb768d17ac3a0ec6 /lib/srv6.h
parent695f387ed872c1bc55ad4149ede95465b48697b9 (diff)
lib, bgpd: Enhance `srv6_locator_chunk_free()` API
A programmer can use the `srv6_locator_chunk_free()` function to free the memory allocated for a `struct srv6_locator_chunk`. The programmer invokes `srv6_locator_chunk_free()` by passing a single pointer to the `struct srv6_locator_chunk` to be freed. `srv6_locator_chunk_free()` uses `XFREE()` to free the memory. It is the responsibility of the programmer to set the `struct srv6_locator_chunk` pointer to NULL after freeing memory with `srv6_locator_chunk_free()`. This commit modifies the `srv6_locator_chunk_free()` function to take a double pointer instead of a single pointer. In this way, setting the `struct srv6_locator_chunk` pointer to NULL is no longer the programmer's responsibility but is the responsibility of `srv6_locator_chunk_free()`. This prevents programmers from making mistakes such as forgetting to set the pointer to NULL after invoking `srv6_locator_chunk_free()`. Signed-off-by: Carmine Scarpitta <carmine.scarpitta@uniroma2.it>
Diffstat (limited to 'lib/srv6.h')
-rw-r--r--lib/srv6.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/srv6.h b/lib/srv6.h
index 6e0c3ce99d..18d5bdebc2 100644
--- a/lib/srv6.h
+++ b/lib/srv6.h
@@ -187,7 +187,7 @@ int snprintf_seg6_segs(char *str,
extern struct srv6_locator *srv6_locator_alloc(const char *name);
extern struct srv6_locator_chunk *srv6_locator_chunk_alloc(void);
extern void srv6_locator_free(struct srv6_locator *locator);
-extern void srv6_locator_chunk_free(struct srv6_locator_chunk *chunk);
+extern void srv6_locator_chunk_free(struct srv6_locator_chunk **chunk);
json_object *srv6_locator_chunk_json(const struct srv6_locator_chunk *chunk);
json_object *srv6_locator_json(const struct srv6_locator *loc);
json_object *srv6_locator_detailed_json(const struct srv6_locator *loc);