ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/include/memory.h
Revision: 31
Committed: Sun Oct 2 20:34:05 2005 UTC (19 years, 10 months ago) by knight
Content type: text/x-chdr
Original Path: ircd-hybrid/include/memory.h
File size: 2148 byte(s)
Log Message:
- Fix svn:keywords

File Contents

# User Rev Content
1 adx 30 /*
2     * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
3     * memory.h: A header for the memory functions.
4     *
5     * Copyright (C) 2002 by the past and present ircd coders, and others.
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
20     * USA
21     *
22 knight 31 * $Id$
23 adx 30 */
24    
25     #ifndef _I_MEMORY_H
26     #define _I_MEMORY_H
27    
28     #include "ircd_defs.h"
29     #include "setup.h"
30     #include "balloc.h"
31    
32     /* Needed to use uintptr_t for some pointer manipulation. */
33    
34     #ifdef HAVE_INTTYPES_H
35     # include <inttypes.h>
36     #else /* No inttypes.h */
37     # ifndef HAVE_UINTPTR_T
38     typedef unsigned long uintptr_t;
39     # endif
40     #endif
41    
42     extern void outofmemory(void);
43    
44     extern void *MyMalloc(size_t size);
45     extern void *MyRealloc(void *x, size_t y);
46     extern void MyFree(void *x);
47     extern void _DupString(char **x, const char *y);
48    
49     /* forte (and maybe others) don't like double declarations,
50     * so we don't declare the inlines unless GNUC
51     */
52     #ifdef __GNUC__
53     extern inline void *
54     MyMalloc(size_t size)
55     {
56     void *ret = calloc(1, size);
57    
58     if (ret == NULL)
59     outofmemory();
60     return(ret);
61     }
62    
63     extern inline void *
64     MyRealloc(void *x, size_t y)
65     {
66     void *ret = realloc(x, y);
67    
68     if (ret == NULL)
69     outofmemory();
70     return(ret);
71     }
72    
73     extern inline void
74     MyFree(void *x)
75     {
76     if (x != NULL)
77     free(x);
78     }
79    
80     extern inline void
81     _DupString(char **x, const char *y)
82     {
83     (*x) = malloc(strlen(y) + 1);
84    
85     if (x == NULL)
86     outofmemory();
87     strcpy((*x), y);
88     }
89     #endif /* __GNUC__ */
90    
91     #define DupString(x,y) _DupString(&x, y)
92     #endif /* _I_MEMORY_H */

Properties

Name Value
svn:eol-style native
svn:keywords "Id Revision"