1/* $Id$ $Revision$ */
2/* vim:set shiftwidth=4 ts=8: */
3
4/*************************************************************************
5 * Copyright (c) 2011 AT&T Intellectual Property
6 * All rights reserved. This program and the accompanying materials
7 * are made available under the terms of the Eclipse Public License v1.0
8 * which accompanies this distribution, and is available at
9 * http://www.eclipse.org/legal/epl-v10.html
10 *
11 * Contributors: See CVS logs. Details at http://www.graphviz.org/
12 *************************************************************************/
13
14#include "vmhdr.h"
15
16/* A discipline to get memory from the heap.
17**
18** Written by Kiem-Phong Vo, kpv@research.att.com, 01/16/94.
19*/
20/**
21 * @param vm region doing allocation from
22 * @param caddr current low address
23 * @param csize current size
24 * @param nsize new size
25 * @param disc discipline structure
26 */
27static void *heapmem(Vmalloc_t * vm, void * caddr,
28 size_t csize, size_t nsize, Vmdisc_t * disc)
29{
30 NOTUSED(vm);
31 NOTUSED(disc);
32
33 if (csize == 0)
34 return vmalloc(Vmheap, nsize);
35 else if (nsize == 0)
36 return vmfree(Vmheap, caddr) >= 0 ? caddr : NIL(void *);
37 else
38 return vmresize(Vmheap, caddr, nsize, 0);
39}
40
41static Vmdisc_t _Vmdcheap = { heapmem, NIL(Vmexcept_f), 0 };
42
43Vmdisc_t* Vmdcheap = &_Vmdcheap;
44