simulavr  1.1.0
avrmalloc.h
Go to the documentation of this file.
1 /*
2  ****************************************************************************
3  *
4  * simulavr - A simulator for the Atmel AVR family of microcontrollers.
5  * Copyright (C) 2001, 2002 Theodore A. Roth
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License along
18  * with this program; if not, write to the Free Software Foundation, Inc.,
19  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20  *
21  ****************************************************************************
22  *
23  * $Id$
24  */
25 
26 #ifndef SIM_AVRMALLOC_H
27 #define SIM_AVRMALLOC_H
28 
29 /* Macros for allocating new memory. Automatically performs type cast. If
30  these definitions are changed, the documentation in avrmalloc.c must be
31  changed. */
32 
40 #define avr_new(type, count) \
41  ((type *) avr_malloc ((unsigned) sizeof (type) * (count)))
42 
43 #define avr_new0(type, count) \
44  ((type *) avr_malloc0 ((unsigned) sizeof (type) * (count)))
45 
46 #define avr_renew(type, mem, count) \
47  ((type *) avr_realloc (mem, (unsigned) sizeof (type) * (count)))
48 
49 /*
50  * Malloc and free wrappers. Perform sanity checks for you.
51  */
52 
53 extern void *avr_malloc (size_t size);
54 extern void *avr_malloc0 (size_t size);
55 extern void *avr_realloc (void *ptr, size_t size);
56 extern char *avr_strdup (const char *s);
57 extern void avr_free (void *ptr);
58 
59 #endif /* SIM_AVRMALLOC_H */
void * avr_malloc(size_t size)
Memory Management Functions.
Definition: avrmalloc.cpp:92
char * avr_strdup(const char *s)
Wrapper for strdup().
Definition: avrmalloc.cpp:164
void * avr_malloc0(size_t size)
Allocate memory and initialize to zero.
Definition: avrmalloc.cpp:115
void * avr_realloc(void *ptr, size_t size)
Wrapper for realloc().
Definition: avrmalloc.cpp:140
void avr_free(void *ptr)
Free malloc'd memory.
Definition: avrmalloc.cpp:182