]> git.ozlabs.org Git - ccan/commitdiff
Preserve errno on talloc_free
authorRusty Russell <rusty@vivaldi>
Thu, 10 Jan 2008 12:28:39 +0000 (23:28 +1100)
committerRusty Russell <rusty@vivaldi>
Thu, 10 Jan 2008 12:28:39 +0000 (23:28 +1100)
talloc/talloc.c
talloc/talloc.h

index 17bb0ec8cc5f3f230615a3514f2e2c4e3b578e5a..e9f531fe58277992767534a345c11dfc0dc9e4ff 100644 (file)
@@ -730,7 +730,11 @@ void *talloc_named_const(const void *context, size_t size, const char *name)
 */
 int talloc_free(void *ptr)
 {
-       return _talloc_free(ptr);
+       int saved_errno = errno, ret;
+       ret = _talloc_free(ptr);
+       if (ret == 0)
+               errno = saved_errno;
+       return ret;
 }
 
 
index f79f45b2fedd9015720be180b98f9b5ad3292669..510cff7599f8d959480b84882b49bd76cfe1e43c 100644 (file)
  * returned for success and -1 for failure. The only possible failure condition
  * is if the pointer had a destructor attached to it and the destructor
  * returned -1. See talloc_set_destructor() for details on destructors.
+ * errno will be preserved unless the talloc_free fails.
  *
  * If this pointer has an additional parent when talloc_free() is called then
  * the memory is not actually released, but instead the most recently