]> git.ozlabs.org Git - ccan/blobdiff - ccan/tal/tal.h
tal/str: new module.
[ccan] / ccan / tal / tal.h
index 3a0481455ae1da5356a8905820190d03702d47eb..42245f68660277c990561502f50b00f94297bcb5 100644 (file)
@@ -53,14 +53,15 @@ typedef void tal_t;
  * @p: NULL, or tal allocated object to free.
  *
  * This calls the destructors for p (if any), then does the same for all its
- * children (recursively) before finally freeing the memory.
+ * children (recursively) before finally freeing the memory.  It returns
+ * NULL, for convenience.
  *
  * Note: errno is preserved by this call.
  *
  * Example:
- *     tal_free(p);
+ *     p = tal_free(p);
  */
-void tal_free(const tal_t *p);
+void *tal_free(const tal_t *p);
 
 /**
  * tal_arr - allocate an array of objects.
@@ -304,7 +305,7 @@ static inline size_t tal_sizeof_(size_t size, size_t count)
 #if HAVE_STATEMENT_EXPR
 /* Careful: ptr can be const foo *, ptype is foo *.  Also, ptr could
  * be an array, eg "hello". */
-#define tal_typechk_(ptr, ptype) ({ __typeof__(&*(ptr)) _p = (ptype)(ptr); _p; })
+#define tal_typechk_(ptr, ptype) ({ __typeof__((ptr)+0) _p = (ptype)(ptr); _p; })
 #else
 #define tal_typechk_(ptr, ptype) (ptr)
 #endif