| 1 |
– |
/* Copyright (c) 1992 Regents of the University of California */ |
| 2 |
– |
|
| 1 |
|
#ifndef lint |
| 2 |
< |
static char SCCSid[] = "$SunId$ LBL"; |
| 2 |
> |
static const char RCSid[] = "$Id$"; |
| 3 |
|
#endif |
| 6 |
– |
|
| 4 |
|
/* |
| 5 |
|
* Fast malloc for memory hogs and VM environments. |
| 6 |
|
* Performs a minimum of searching through free lists. |
| 19 |
|
* Greg Ward Lawrence Berkeley Laboratory |
| 20 |
|
*/ |
| 21 |
|
|
| 22 |
+ |
/* ==================================================================== |
| 23 |
+ |
* The Radiance Software License, Version 1.0 |
| 24 |
+ |
* |
| 25 |
+ |
* Copyright (c) 1990 - 2002 The Regents of the University of California, |
| 26 |
+ |
* through Lawrence Berkeley National Laboratory. All rights reserved. |
| 27 |
+ |
* |
| 28 |
+ |
* Redistribution and use in source and binary forms, with or without |
| 29 |
+ |
* modification, are permitted provided that the following conditions |
| 30 |
+ |
* are met: |
| 31 |
+ |
* |
| 32 |
+ |
* 1. Redistributions of source code must retain the above copyright |
| 33 |
+ |
* notice, this list of conditions and the following disclaimer. |
| 34 |
+ |
* |
| 35 |
+ |
* 2. Redistributions in binary form must reproduce the above copyright |
| 36 |
+ |
* notice, this list of conditions and the following disclaimer in |
| 37 |
+ |
* the documentation and/or other materials provided with the |
| 38 |
+ |
* distribution. |
| 39 |
+ |
* |
| 40 |
+ |
* 3. The end-user documentation included with the redistribution, |
| 41 |
+ |
* if any, must include the following acknowledgment: |
| 42 |
+ |
* "This product includes Radiance software |
| 43 |
+ |
* (http://radsite.lbl.gov/) |
| 44 |
+ |
* developed by the Lawrence Berkeley National Laboratory |
| 45 |
+ |
* (http://www.lbl.gov/)." |
| 46 |
+ |
* Alternately, this acknowledgment may appear in the software itself, |
| 47 |
+ |
* if and wherever such third-party acknowledgments normally appear. |
| 48 |
+ |
* |
| 49 |
+ |
* 4. The names "Radiance," "Lawrence Berkeley National Laboratory" |
| 50 |
+ |
* and "The Regents of the University of California" must |
| 51 |
+ |
* not be used to endorse or promote products derived from this |
| 52 |
+ |
* software without prior written permission. For written |
| 53 |
+ |
* permission, please contact [email protected]. |
| 54 |
+ |
* |
| 55 |
+ |
* 5. Products derived from this software may not be called "Radiance", |
| 56 |
+ |
* nor may "Radiance" appear in their name, without prior written |
| 57 |
+ |
* permission of Lawrence Berkeley National Laboratory. |
| 58 |
+ |
* |
| 59 |
+ |
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED |
| 60 |
+ |
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
| 61 |
+ |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 62 |
+ |
* DISCLAIMED. IN NO EVENT SHALL Lawrence Berkeley National Laboratory OR |
| 63 |
+ |
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 64 |
+ |
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 65 |
+ |
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF |
| 66 |
+ |
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
| 67 |
+ |
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
| 68 |
+ |
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT |
| 69 |
+ |
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 70 |
+ |
* SUCH DAMAGE. |
| 71 |
+ |
* ==================================================================== |
| 72 |
+ |
* |
| 73 |
+ |
* This software consists of voluntary contributions made by many |
| 74 |
+ |
* individuals on behalf of Lawrence Berkeley National Laboratory. For more |
| 75 |
+ |
* information on Lawrence Berkeley National Laboratory, please see |
| 76 |
+ |
* <http://www.lbl.gov/>. |
| 77 |
+ |
*/ |
| 78 |
+ |
|
| 79 |
|
#include <errno.h> |
| 80 |
|
|
| 81 |
|
#ifndef BSD |
| 97 |
|
#define NULL 0 |
| 98 |
|
#endif |
| 99 |
|
|
| 100 |
< |
#ifndef ALIGN |
| 101 |
< |
#define ALIGN int /* align type */ |
| 100 |
> |
#ifndef ALIGNT |
| 101 |
> |
#define ALIGNT int /* align type */ |
| 102 |
|
#endif |
| 103 |
< |
#define BYTES_WORD sizeof(ALIGN) |
| 103 |
> |
#define BYTES_WORD sizeof(ALIGNT) |
| 104 |
|
|
| 105 |
|
#ifndef MAXINCR |
| 106 |
|
#define MAXINCR (1<<16) /* largest sbrk(2) increment */ |
| 112 |
|
short magic; |
| 113 |
|
short bucket; |
| 114 |
|
} a; |
| 115 |
< |
ALIGN dummy; |
| 115 |
> |
ALIGNT dummy; |
| 116 |
|
} M_HEAD; |
| 117 |
|
|
| 118 |
|
#define MAGIC 0x1a2 /* magic number for allocated memory */ |
| 122 |
|
|
| 123 |
|
static M_HEAD *free_list[NBUCKETS]; |
| 124 |
|
|
| 125 |
< |
static ALIGN dummy_mem; |
| 125 |
> |
static ALIGNT dummy_mem; |
| 126 |
|
|
| 127 |
|
static char *memlim[2]; |
| 128 |
|
|