Plan 9 from Bell Labs’s /usr/web/sources/patch/applied/setmalloctag-libsec-libmp/notes

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


Mon Sep 19 07:15:50 EDT 2005 rsc
    I edited this patch before applying it, to remove some of
    the calls to setmalloctag.  betomp illustrates the general
    philosophy.  It looks like this:
    
    mpint*
    betomp(int n)
    {
    	b = malloc(sizeof *b);
    	b->p = malloc(n);
    	return b;
    }
    
    In this case, b should get tagged with setmalloctag,
    because the responsibility for freeing (via mpfree)
    b is being passed to the caller.  b->p, on the other
    hand, has a fine malloc tag as it is.  The caller is
    not responsible for freeing b->p.  b->p is hidden from
    the caller and expected to be freed by the innards of
    mpfree.  
    

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].