talloc: avoid a function call in TALLOC_FREE() if possible.
authorStefan Metzmacher <metze@samba.org>
Wed, 4 Dec 2013 14:35:37 +0000 (15:35 +0100)
committerStefan Metzmacher <metze@samba.org>
Tue, 10 Mar 2015 09:55:39 +0000 (10:55 +0100)
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
(cherry picked from commit b9fcfc6399eab750880ee0b9806311dd351a8ff6)

lib/talloc/talloc.h

index 5d29a8d5cf050f9ec5d4f16e81885e6437e6b9ee..0d47d23b2ff570db1ff0d5e6ef1cf389c4e8fc64 100644 (file)
@@ -893,7 +893,7 @@ void *_talloc_pooled_object(const void *ctx,
  *
  * @param[in]  ctx      The chunk to be freed.
  */
-#define TALLOC_FREE(ctx) do { talloc_free(ctx); ctx=NULL; } while(0)
+#define TALLOC_FREE(ctx) do { if (ctx != NULL) { talloc_free(ctx); ctx=NULL; } } while(0)
 
 /* @} ******************************************************************/