1
2
3 #ifndef COMMON_H
4 #define COMMON_H
5
6 #include "stdlib.h"
7 #include "string.h"
8
9 #define RNN_INLINE inline
10 #define OPUS_INLINE inline
11
12
13 /** RNNoise wrapper for malloc(). To do your own dynamic allocation, all you need t
14 o do is replace this function and rnnoise_free */
15 #ifndef OVERRIDE_RNNOISE_ALLOC
rnnoise_alloc(size_t size)16 static RNN_INLINE void *rnnoise_alloc (size_t size)
17 {
18 return malloc(size);
19 }
20 #endif
21
22 /** RNNoise wrapper for free(). To do your own dynamic allocation, all you need to do is replace this function and rnnoise_alloc */
23 #ifndef OVERRIDE_RNNOISE_FREE
rnnoise_free(void * ptr)24 static RNN_INLINE void rnnoise_free (void *ptr)
25 {
26 free(ptr);
27 }
28 #endif
29
30 /** Copy n elements from src to dst. The 0* term provides compile-time type checking */
31 #ifndef OVERRIDE_RNN_COPY
32 #define RNN_COPY(dst, src, n) (memcpy((dst), (src), (n)*sizeof(*(dst)) + 0*((dst)-(src)) ))
33 #endif
34
35 /** Copy n elements from src to dst, allowing overlapping regions. The 0* term
36 provides compile-time type checking */
37 #ifndef OVERRIDE_RNN_MOVE
38 #define RNN_MOVE(dst, src, n) (memmove((dst), (src), (n)*sizeof(*(dst)) + 0*((dst)-(src)) ))
39 #endif
40
41 /** Set n elements of dst to zero */
42 #ifndef OVERRIDE_RNN_CLEAR
43 #define RNN_CLEAR(dst, n) (memset((dst), 0, (n)*sizeof(*(dst))))
44 #endif
45
46
47
48 #endif
49