[master] 4edaa2836 Use FREE_OBJ for VEV

Dridi Boukelmoune dridi.boukelmoune at gmail.com
Fri Mar 22 07:35:08 UTC 2019


commit 4edaa2836c6aba837899b78866a2567c704e336b
Author: Dridi Boukelmoune <dridi.boukelmoune at gmail.com>
Date:   Fri Mar 22 08:24:38 2019 +0100

    Use FREE_OBJ for VEV
    
    This was actually done with a Coccinelle patch after finding plain
    free() calls out of tree:
    
        $ cat >free_obj.cocci <<EOF
        @@
        expression obj, objp, magic;
        @@
    
        (
        TAKE_OBJ_NOTNULL(obj, objp, magic);
        |
        CAST_OBJ_NOTNULL(obj, objp, magic);
        |
        CHECK_OBJ_NOTNULL(obj, magic);
        |
        CHECK_OBJ_ORNULL(obj, magic);
        |
        CHECK_OBJ(obj, magic);
        )
        ...
        - free(obj);
        + FREE_OBJ(obj);
        $ spatch --dir . --in-place --sp-file free_obj.cocci
    
    Asking again, could we consider keeping Coccinelle patches around?

diff --git a/lib/libvarnish/vev.c b/lib/libvarnish/vev.c
index 7869f700f..dcb712a2e 100644
--- a/lib/libvarnish/vev.c
+++ b/lib/libvarnish/vev.c
@@ -222,9 +222,8 @@ VEV_Destroy(struct vev_root **evbp)
 	assert(evb->thread == pthread_self());
 	free(evb->pfd);
 	free(evb->pev);
-	/* destroy evb->binheap */
-	evb->magic = 0;
-	free(evb);
+	/* XXX: destroy evb->binheap */
+	FREE_OBJ(evb);
 }
 
 /*--------------------------------------------------------------------*/


More information about the varnish-commit mailing list