Lumiera  0.pre.03
»edit your freedom«
safeclib.h
Go to the documentation of this file.
1 /*
2  SAFECLIB.h - Portable and safe wrappers around some clib functions and some tools
3 
4  Copyright (C)
5  2008, Christian Thaeter <ct@pipapo.org>
6 
7  This program is free software; you can redistribute it and/or
8  modify it under the terms of the GNU General Public License as
9  published by the Free Software Foundation; either version 2 of
10  the License, or (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., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */
21 
22 
28 #include "error.h"
29 
30 #include <stdlib.h>
31 
32 LUMIERA_ERROR_DECLARE(NO_MEMORY);
33 
42 void
44 
45 
52 void*
53 lumiera_malloc (size_t sz);
54 
55 
63 void*
64 lumiera_calloc (size_t n, size_t size);
65 
66 
73 void*
74 lumiera_realloc (void* ptr, size_t size);
75 
76 
81 static inline void
82 lumiera_free (void* mem)
83 {
84  /* for now only a alias, might change in future */
85  free (mem);
86 }
87 
88 
96 char*
97 lumiera_strndup (const char* str, size_t len);
98 
99 
108 int
109 lumiera_strncmp (const char* a, const char* b, size_t len);
110 
111 
118 int
119 lumiera_streq (const char* a, const char* b);
120 
121 /*
122 // Local Variables:
123 // mode: C
124 // c-file-style: "gnu"
125 // indent-tabs-mode: nil
126 // End:
127 */
#define LUMIERA_ERROR_DECLARE(err)
Forward declare an error constant.
Definition: error.h:71
int lumiera_streq(const char *a, const char *b)
check 2 strings for identity.
Definition: safeclib.c:200
static void lumiera_free(void *mem)
Free previously allocated memory.
Definition: safeclib.h:82
Lumiera error handling (C interface).
int lumiera_strncmp(const char *a, const char *b, size_t len)
Compare two C strings.
Definition: safeclib.c:193
void * lumiera_calloc(size_t n, size_t size)
Allocate cleared memory for an array.
Definition: safeclib.c:139
void * lumiera_realloc(void *ptr, size_t size)
Change the size of a memory block.
Definition: safeclib.c:158
void * lumiera_malloc(size_t sz)
Allocate memory.
Definition: safeclib.c:122
char * lumiera_strndup(const char *str, size_t len)
Duplicate a C string.
Definition: safeclib.c:175
void lumiera_safeclib_set_resourcecollector(void *hook)
Install the resourcecollector run hook.