ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/hopm/trunk/src/memory.c
Revision: 5876
Committed: Wed Apr 29 11:25:48 2015 UTC (10 years, 4 months ago) by michael
Content type: text/x-csrc
File size: 1532 byte(s)
Log Message:
- Removed trailing whitespaces

File Contents

# Content
1 /*
2 * Copyright (c) 2002 Erik Fears
3 * Copyright (c) 2014-2015 ircd-hybrid development team
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
18 * USA
19 */
20
21 #include <stdlib.h>
22 #include <assert.h>
23 #include <string.h>
24
25 #include "memory.h"
26
27
28 /* xcalloc
29 *
30 * A wrapper function for malloc(), for catching memory issues
31 * and error handling.
32 *
33 * Parameters
34 * bytes: amount in bytes to allocate
35 *
36 * Return:
37 * Pointer to allocated memory
38 */
39
40 void *xcalloc(size_t bytes)
41 {
42 void *ret = calloc(1, bytes);
43 assert(ret);
44
45 return ret;
46 }
47
48
49
50 /* xfree
51 *
52 * Free memory allocated with xcalloc
53 *
54 * Parameters:
55 * var: pointer to memory to free
56 *
57 * Return:
58 * None
59 */
60
61 void xfree(void *ptr)
62 {
63 free(ptr);
64 }
65
66 void *
67 xstrdup(const char *s)
68 {
69 void *ret = malloc(strlen(s) + 1);
70
71 assert(ret);
72 strcpy(ret, s);
73
74 return ret;
75 }

Properties

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