forked from trema/trema
/
wrapper.h
78 lines (61 loc) · 1.91 KB
/
wrapper.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/*
* Wrappers that simplifies the handling of memory allocation errors.
*
* Author: Yasuhito Takamiya <yasuhito@gmail.com>
*
* Copyright (C) 2008-2012 NEC Corporation
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, version 2, as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef WRAPPER_H
#define WRAPPER_H
#include <stdarg.h>
#include <stddef.h>
#include <string.h>
#include "utility.h"
// If this is being built for a unit test.
#ifdef UNIT_TESTING
// Redirect assert to mock_assert() so assertions can be caught by cmockery.
#ifdef assert
#undef assert
#endif // assert
#define assert( expression ) \
mock_assert( ( int ) ( expression ), #expression, __FILE__, __LINE__ );
extern void mock_assert( const int result, const char *const expression, const char *const file, const int line );
#endif // UNIT_TESTING
// Undef Ruby's xmalloc()
#ifdef xmalloc
#undef xmalloc
#endif
void *xmalloc( size_t size );
// Undef Ruby's xcalloc()
#ifdef xcalloc
#undef xcalloc
#endif
void *xcalloc( size_t nmemb, size_t size );
// Undef Ruby's xfree()
#ifdef xfree
#undef xfree
#endif
void xfree( void *ptr );
char *xstrdup( const char *s );
char *xvasprintf( const char *format, va_list args );
char *xasprintf( const char *format, ... );
#endif // WRAPPER_H
/*
* Local variables:
* c-basic-offset: 2
* indent-tabs-mode: nil
* End:
*/