]>
Commit | Line | Data |
---|---|---|
1 | /* | |
2 | $Header: /cvs/src/tdl/memory.h,v 1.1.2.1 2004/01/07 00:09:05 richard Exp $ | |
3 | ||
4 | tdl - A console program for managing to-do lists | |
5 | Copyright (C) 2001-2004 Richard P. Curnow | |
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 | |
18 | along with this program; if not, write to the Free Software | |
19 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA | |
20 | */ | |
21 | ||
22 | #ifndef MEMORY_H | |
23 | #define MEMORY_H | |
24 | #include <stdlib.h> | |
25 | ||
26 | #define new_string(s) strcpy((char *) malloc(1+strlen(s)), (s)) | |
27 | #define extend_string(x,s) (strcat(realloc(x, (strlen(x)+strlen(s)+1)), s)) | |
28 | #define new(T) (T *) malloc(sizeof(T)) | |
29 | #define new_array(T, n) (T *) malloc(sizeof(T) * (n)) | |
30 | #define grow_array(T, n, oldX) (T *) ((oldX) ? realloc(oldX, (sizeof(T) * (n))) : malloc(sizeof(T) * (n))) | |
31 | #endif | |
32 |