ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/hopm/branches/1.0.x/src/memory.c
Revision: 5349
Committed: Sun Jan 11 12:58:17 2015 UTC (11 years, 7 months ago) by michael
Content type: text/x-csrc
File size: 1571 byte(s)
Log Message:
- memory.c, memory.h: fixed header inclusions

File Contents

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

Properties

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