From: Rusty Russell Date: Sat, 18 Jul 2009 08:13:33 +0000 (+0930) Subject: talloc_free() should take a const void *, a-la free(). X-Git-Url: https://git.ozlabs.org/?p=ccan;a=commitdiff_plain;h=d419d5c947a4191aa5dffdcb7c5142ce58457d3d;hp=3c81225fc0a4fb99d10282ebf11b7ec6ae1eabdd talloc_free() should take a const void *, a-la free(). --- diff --git a/ccan/talloc/talloc.c b/ccan/talloc/talloc.c index 1424748e..7a2dfab1 100644 --- a/ccan/talloc/talloc.c +++ b/ccan/talloc/talloc.c @@ -819,12 +819,12 @@ void *talloc_named_const(const void *context, size_t size, const char *name) will not be freed if the ref_count is > 1 or the destructor (if any) returns non-zero */ -int talloc_free(void *ptr) +int talloc_free(const void *ptr) { int saved_errno = errno, ret; lock(ptr); - ret = _talloc_free(ptr); + ret = _talloc_free(discard_const_p(void, ptr)); unlock(); if (ret == 0) errno = saved_errno; diff --git a/ccan/talloc/talloc.h b/ccan/talloc/talloc.h index 791c98a2..e38d05b8 100644 --- a/ccan/talloc/talloc.h +++ b/ccan/talloc/talloc.h @@ -119,7 +119,7 @@ * See Also: * talloc_set_destructor, talloc_unlink */ -int talloc_free(void *ptr); +int talloc_free(const void *ptr); /** * talloc_set_destructor: set a destructor for when this pointer is freed