* ========== Copyright Header Begin ==========================================
* OpenSPARC T2 Processor File: allocate.c
* Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES.
* The above named program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License version 2 as published by the Free Software Foundation.
* The above named program is distributed in the hope that it will be
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
* You should have received a copy of the GNU General Public
* License along with this work; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
* ========== Copyright Header End ============================================
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
#pragma ident "@(#)allocate.c 1.6 06/08/15 SMI"
* Simple allocation routines
void * xmalloc(size_t size
, int linen
, char * filen
)
if (size
<0) fatal("xmalloc of negative size (%d) at %d in %s",
warning("xmalloc of zero size at %d in %s", linen
, filen
);
if (p
== (void*)0) fatal("malloc of %d at %d in %s", size
, linen
, filen
);
void * xcalloc(size_t num
, size_t size
, int linen
, char * filen
)
fatal("xcalloc(%d,%d) : one of number or size is <= 0 at line %d of %s",
num
, size
, linen
, filen
);
if (p
== (void*)0) fatal("calloc of %d of size %d at %d in %s", num
, size
, linen
, filen
);
void xfree(void * p
, int linen
, char * filen
)
warning("xfree of null pointer at %d in %s", linen
, filen
);
void * xrealloc(void * oldp
, size_t size
, int linen
, char * filen
)
xfree(oldp
, linen
, filen
);
warning("xrealloc to zero size at %d in %s", linen
, filen
);
fatal("xrealloc to negative size %d at %d in %s", size
, linen
, filen
);
if (p
== (void*)0) fatal("xrealloc failed @ %d in %s", linen
, filen
);
char * xstrdup(char * strp
, int linen
, char * filen
)
if (p
== (char*)0) fatal("xstrdup @ %d in %s failed", linen
, filen
);