8322 nl: misleading-indentation
[unleashed/tickless.git] / usr / src / lib / libtnfprobe / probe_mem.c
blob91e73350ab924f83ff627eb0b276e40b0d92c226
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
7 * with the License.
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
20 * CDDL HEADER END
23 * Copyright (c) 1994, by Sun Microsytems, Inc.
26 #pragma ident "%Z%%M% %I% %E% SMI"
29 * Includes
32 #include "prb_internals.h"
36 * Globals
37 * Memory that prex uses to store combinations in target process
40 #define INITMEMSZ 2048
42 static char initial_memory[INITMEMSZ];
43 static tnf_memseg_t initial_memseg = {
44 initial_memory,
45 initial_memory + INITMEMSZ,
46 DEFAULTMUTEX,
50 tnf_memseg_t * __tnf_probe_memseg_p = &initial_memseg;
54 * __tnf_probe_alloc() - allocates memory from the global pool
57 char *
58 __tnf_probe_alloc(size_t size)
60 tnf_memseg_t * memseg_p = __tnf_probe_memseg_p;
61 char * ptr;
63 ptr = NULL;
65 mutex_lock(&memseg_p->i_lock);
67 memseg_p->i_reqsz = size;
69 if ((memseg_p->min_p + size) <= memseg_p->max_p) {
70 ptr = memseg_p->min_p;
71 memseg_p->min_p += size;
74 memseg_p->i_reqsz = 0;
76 mutex_unlock(&memseg_p->i_lock);
78 return (ptr);
80 } /* end __tnf_probe_alloc */