xref: /titanic_50/usr/src/lib/libast/common/vmalloc/vmgetmem.c (revision 29e83d4b25fd82feb8e0e0fbe89f7e2a8438533d)
1 /***********************************************************************
2 *                                                                      *
3 *               This software is part of the ast package               *
4 *           Copyright (c) 1985-2007 AT&T Knowledge Ventures            *
5 *                      and is licensed under the                       *
6 *                  Common Public License, Version 1.0                  *
7 *                      by AT&T Knowledge Ventures                      *
8 *                                                                      *
9 *                A copy of the License is available at                 *
10 *            http://www.opensource.org/licenses/cpl1.0.txt             *
11 *         (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9)         *
12 *                                                                      *
13 *              Information and Software Systems Research               *
14 *                            AT&T Research                             *
15 *                           Florham Park NJ                            *
16 *                                                                      *
17 *                 Glenn Fowler <gsf@research.att.com>                  *
18 *                  David Korn <dgk@research.att.com>                   *
19 *                   Phong Vo <kpv@research.att.com>                    *
20 *                                                                      *
21 ***********************************************************************/
22 #if defined(_UWIN) && defined(_BLD_ast)
23 
24 void _STUB_vmgetmem(){}
25 
26 #else
27 
28 #include	"vmhdr.h"
29 
30 /*
31  * vm open/close/resize - a handy default for discipline memory functions
32  *
33  *	vmgetmem(0,0,0)		open new region
34  *	vmgetmem(r,0,0)		free region
35  *	vmgetmem(r,0,n)		allocate n bytes initialized to 0
36  *	vmgetmem(r,p,0)		free p
37  *	vmgetmem(r,p,n)		realloc p to n bytes
38  */
39 
40 #if __STD_C
41 Void_t* vmgetmem(Vmalloc_t* vm, Void_t* data, size_t size)
42 #else
43 Void_t* vmgetmem(vm, data, size)
44 Vmalloc_t*	vm;
45 Void_t*		data;
46 size_t		size;
47 #endif
48 {
49 	if (!vm)
50 		return vmopen(Vmdcheap, Vmbest, 0);
51 	if (data || size)
52 		return vmresize(vm, data, size, VM_RSMOVE|VM_RSCOPY|VM_RSZERO);
53 	vmclose(vm);
54 	return 0;
55 }
56 
57 #endif
58