This repository was archived by the owner on Nov 20, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommon.h
More file actions
64 lines (52 loc) · 1.82 KB
/
common.h
File metadata and controls
64 lines (52 loc) · 1.82 KB
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
/* common.h
*
* Copyright (C) 2009 Francesco Abbate
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* 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 COMMON_H
#define COMMON_H
#include <stdlib.h>
#include <math.h>
#include "defs.h"
__BEGIN_DECLS
#define DEGREE(d) ((d) * M_PI / 180.0)
#define SQR(x) ((x) * (x))
#ifdef DEBUG_MEM
#define emalloc(n) malloc((size_t) (n))
#define erealloc(x,n) realloc(x,(size_t) (n))
#else
#define emalloc(n) erealloc(NULL, n);
extern void * erealloc (void *p, int n);
#endif
#ifdef WIN32
#define DIR_SEPARATOR '\\'
#else
#define DIR_SEPARATOR '/'
#endif
struct generic_array {
size_t number;
size_t alloc;
void *heap;
};
extern void generic_array_check_alloc (struct generic_array *s, int index,
size_t data_size);
extern void * generic_array_new (size_t data_size);
extern void generic_array_free (struct generic_array *r);
#define ARRAY_CHECK_ALLOC(s,dtype,idx) generic_array_check_alloc((struct generic_array *) (s),idx,sizeof(dtype))
#define ARRAY_NEW(dtype) generic_array_new(sizeof(dtype))
#define ARRAY_FREE(s) generic_array_free(s)
__END_DECLS
#endif