talloc: Simplify _talloc_free_poolmem a bit
authorVolker Lendecke <vl@samba.org>
Mon, 15 Apr 2013 20:19:25 +0000 (22:19 +0200)
committerJeremy Allison <jra@samba.org>
Thu, 18 Apr 2013 20:50:42 +0000 (22:50 +0200)
Early returns are easier to understand than "else if"

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Thu Apr 18 22:50:42 CEST 2013 on sn-devel-104

lib/talloc/talloc.c

index 0078b07ca67f7353deb6bd66888913444c78515e..885d7006e65cfd32a89dc18aa7b32c9374a527ad 100644 (file)
@@ -794,7 +794,10 @@ static inline void _talloc_free_poolmem(struct talloc_chunk *tc,
                 */
                pool->hdr.c.pool = tc_pool_first_chunk(pool);
                tc_invalidate_pool(pool);
-       } else if (unlikely(pool->hdr.object_count == 0)) {
+               return;
+       }
+
+       if (unlikely(pool->hdr.object_count == 0)) {
                /*
                 * we mark the freed memory with where we called the free
                 * from. This means on a double free error we can report where
@@ -804,14 +807,23 @@ static inline void _talloc_free_poolmem(struct talloc_chunk *tc,
 
                TC_INVALIDATE_FULL_CHUNK(&pool->hdr.c);
                free(pool);
-       } else if (pool->hdr.c.pool == next_tc) {
+               return;
+       }
+
+       if (pool->hdr.c.pool == next_tc) {
                /*
                 * if pool->pool still points to end of
                 * 'tc' (which is stored in the 'next_tc' variable),
                 * we can reclaim the memory of 'tc'.
                 */
                pool->hdr.c.pool = tc;
+               return;
        }
+
+       /*
+        * Do nothing. The memory is just "wasted", waiting for the pool
+        * itself to be freed.
+        */
 }
 
 static inline void _talloc_free_children_internal(struct talloc_chunk *tc,