talloc: save errno over talloc_free
authorRusty Russell <rusty@rustcorp.com.au>
Mon, 7 Dec 2009 12:35:58 +0000 (23:05 +1030)
committerRusty Russell <rusty@rustcorp.com.au>
Mon, 7 Dec 2009 12:35:58 +0000 (23:05 +1030)
As we start to use errno more, it's a huge pain if talloc_free() can blatt
it (esp. destructors).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
lib/talloc/talloc.c

index b805c9725cd361213fe345d535b35510f473c601..8e11a1121829d2f05b8e77072e78bec54c9b0f3c 100644 (file)
@@ -746,7 +746,12 @@ void *talloc_named_const(const void *context, size_t size, const char *name)
 */
 int talloc_free(void *ptr)
 {
-       return _talloc_free(ptr);
+       int ret, saved_errno;
+
+       saved_errno = errno;
+       ret = _talloc_free(ptr);
+       errno = saved_errno;
+       return ret;
 }