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   **Lumiera** is free software; you can redistribute it and/or modify it
8   under the terms of the GNU General Public License as published by the
9   Free Software Foundation; either version 2 of the License, or (at your
10   option) any later version. See the file COPYING for further details.
11 */
12 
13 
19 #include "error.h"
20 
21 #include <stdlib.h>
22 
23 LUMIERA_ERROR_DECLARE(NO_MEMORY);
24 
33 void
35 
36 
43 void*
44 lumiera_malloc (size_t sz);
45 
46 
54 void*
55 lumiera_calloc (size_t n, size_t size);
56 
57 
64 void*
65 lumiera_realloc (void* ptr, size_t size);
66 
67 
72 static inline void
73 lumiera_free (void* mem)
74 {
75  /* for now only a alias, might change in future */
76  free (mem);
77 }
78 
79 
87 char*
88 lumiera_strndup (const char* str, size_t len);
89 
90 
99 int
100 lumiera_strncmp (const char* a, const char* b, size_t len);
101 
102 
109 int
110 lumiera_streq (const char* a, const char* b);
111 
112 /*
113 // Local Variables:
114 // mode: C
115 // c-file-style: "gnu"
116 // indent-tabs-mode: nil
117 // End:
118 */
#define LUMIERA_ERROR_DECLARE(err)
Forward declare an error constant.
Definition: error.h:62
int lumiera_streq(const char *a, const char *b)
check 2 strings for identity.
Definition: safeclib.c:191
static void lumiera_free(void *mem)
Free previously allocated memory.
Definition: safeclib.h:73
Lumiera error handling (C interface).
int lumiera_strncmp(const char *a, const char *b, size_t len)
Compare two C strings.
Definition: safeclib.c:184
void * lumiera_calloc(size_t n, size_t size)
Allocate cleared memory for an array.
Definition: safeclib.c:130
void * lumiera_realloc(void *ptr, size_t size)
Change the size of a memory block.
Definition: safeclib.c:149
void * lumiera_malloc(size_t sz)
Allocate memory.
Definition: safeclib.c:113
char * lumiera_strndup(const char *str, size_t len)
Duplicate a C string.
Definition: safeclib.c:166
void lumiera_safeclib_set_resourcecollector(void *hook)
Install the resourcecollector run hook.