/***********************************************************************1* *2* This software is part of the ast package *3* Copyright (c) 1985-2011 AT&T Intellectual Property *4* and is licensed under the *5* Eclipse Public License, Version 1.0 *6* by AT&T Intellectual Property *7* *8* A copy of the License is available at *9* http://www.eclipse.org/org/documents/epl-v10.html *10* (with md5 checksum b35adb5213ca9657e911e9befb180842) *11* *12* Information and Software Systems Research *13* AT&T Research *14* Florham Park NJ *15* *16* Glenn Fowler <[email protected]> *17* David Korn <[email protected]> *18* Phong Vo <[email protected]> *19* *20***********************************************************************/21#if defined(_UWIN) && defined(_BLD_ast)2223void _STUB_vmclear(){}2425#else2627#include "vmhdr.h"2829/* Clear out all allocated space.30**31** Written by Kiem-Phong Vo, [email protected], 01/16/94.32*/33#if __STD_C34int vmclear(Vmalloc_t* vm)35#else36int vmclear(vm)37Vmalloc_t* vm;38#endif39{40Seg_t *seg, *next;41Block_t *tp;42size_t size, s;43Vmdata_t *vd = vm->data;4445SETLOCK(vm, 0);4647vd->free = vd->wild = NIL(Block_t*);48vd->pool = 0;4950if(vd->mode&(VM_MTBEST|VM_MTDEBUG|VM_MTPROFILE) )51{ vd->root = NIL(Block_t*);52for(s = 0; s < S_TINY; ++s)53TINY(vd)[s] = NIL(Block_t*);54for(s = 0; s <= S_CACHE; ++s)55CACHE(vd)[s] = NIL(Block_t*);56}5758for(seg = vd->seg; seg; seg = next)59{ next = seg->next;6061tp = SEGBLOCK(seg);62size = seg->baddr - ((Vmuchar_t*)tp) - 2*sizeof(Head_t);6364SEG(tp) = seg;65SIZE(tp) = size;66if((vd->mode&(VM_MTLAST|VM_MTPOOL)) )67seg->free = tp;68else69{ SIZE(tp) |= BUSY|JUNK;70LINK(tp) = CACHE(vd)[C_INDEX(SIZE(tp))];71CACHE(vd)[C_INDEX(SIZE(tp))] = tp;72}7374tp = BLOCK(seg->baddr);75SEG(tp) = seg;76SIZE(tp) = BUSY;77}7879CLRLOCK(vm, 0);8081return 0;82}8384#endif858687