binyo 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2012-2013 Martin Boßlet
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,38 @@
1
+ /*
2
+ * binyo - Fast binary IO for Ruby
3
+ *
4
+ * Copyright (c) 2012-2013
5
+ * Martin Bosslet <martin.bosslet@gmail.com>
6
+ * All rights reserved.
7
+ *
8
+ * Permission is hereby granted, free of charge, to any person obtaining
9
+ * a copy of this software and associated documentation files (the
10
+ * "Software"), to deal in the Software without restriction, including
11
+ * without limitation the rights to use, copy, modify, merge, publish,
12
+ * distribute, sublicense, and/or sell copies of the Software, and to
13
+ * permit persons to whom the Software is furnished to do so, subject to
14
+ * the following conditions:
15
+ *
16
+ * The above copyright notice and this permission notice shall be
17
+ * included in all copies or substantial portions of the Software.
18
+ *
19
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
22
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
23
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
24
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
25
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26
+ */
27
+
28
+ #ifndef _BINYO_ERROR_INTERNAL_H_
29
+ #define _BINYO_ERROR_INTERNAL_H_
30
+
31
+ void binyo_add_io_error(void);
32
+ void binyo_error_add(const char *format, ...);
33
+
34
+ VALUE binyo_error_create(VALUE exception_class, const char *format, ...);
35
+ void binyo_error_raise(VALUE exception_class, const char *format, ...);
36
+
37
+ #endif /* BINYO_ERROR_INTERNAL_H */
38
+
@@ -0,0 +1,41 @@
1
+ /*
2
+ * binyo - Fast binary IO for Ruby
3
+ *
4
+ * Copyright (c) 2012-2013
5
+ * Martin Bosslet <martin.bosslet@gmail.com>
6
+ * All rights reserved.
7
+ *
8
+ * Permission is hereby granted, free of charge, to any person obtaining
9
+ * a copy of this software and associated documentation files (the
10
+ * "Software"), to deal in the Software without restriction, including
11
+ * without limitation the rights to use, copy, modify, merge, publish,
12
+ * distribute, sublicense, and/or sell copies of the Software, and to
13
+ * permit persons to whom the Software is furnished to do so, subject to
14
+ * the following conditions:
15
+ *
16
+ * The above copyright notice and this permission notice shall be
17
+ * included in all copies or substantial portions of the Software.
18
+ *
19
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
22
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
23
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
24
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
25
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26
+ */
27
+
28
+ #ifndef _BINYO_ERROR_H_
29
+ #define _BINYO_ERROR_H_
30
+
31
+ #define BINYO_OK 1
32
+ #define BINYO_ERR -1
33
+
34
+ #define BINYO_IO_EOF -2
35
+
36
+ int binyo_has_errors(void);
37
+ int binyo_error_message(char *buf, int buf_len);
38
+ void binyo_error_clear(void);
39
+
40
+ #endif /* BINYO_ERROR_H */
41
+
@@ -0,0 +1,54 @@
1
+ /*
2
+ * binyo - Fast binary IO for Ruby
3
+ *
4
+ * Copyright (c) 2012-2013
5
+ * Martin Bosslet <martin.bosslet@gmail.com>
6
+ * All rights reserved.
7
+ *
8
+ * Permission is hereby granted, free of charge, to any person obtaining
9
+ * a copy of this software and associated documentation files (the
10
+ * "Software"), to deal in the Software without restriction, including
11
+ * without limitation the rights to use, copy, modify, merge, publish,
12
+ * distribute, sublicense, and/or sell copies of the Software, and to
13
+ * permit persons to whom the Software is furnished to do so, subject to
14
+ * the following conditions:
15
+ *
16
+ * The above copyright notice and this permission notice shall be
17
+ * included in all copies or substantial portions of the Software.
18
+ *
19
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
22
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
23
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
24
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
25
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26
+ */
27
+
28
+ #if !defined(_BINYO_IO_BUFFER_H_)
29
+ #define _BINYO_IO_BUFFER_H_
30
+
31
+ #include <ruby.h>
32
+
33
+ #define BINYO_BYTE_BUFFER_GROWTH_FACTOR 2
34
+
35
+ typedef struct binyo_byte_buffer_st {
36
+ size_t size;
37
+ size_t limit;
38
+ size_t init_size;
39
+ int prealloc; /* whether the buffer was already preallocated */
40
+ uint8_t *data;
41
+ } binyo_byte_buffer;
42
+
43
+ #define binyo_buffer_get_data(b) (b)->data
44
+ #define binyo_buffer_get_size(b) (b)->size
45
+ binyo_byte_buffer *binyo_buffer_new(void);
46
+ binyo_byte_buffer *binyo_buffer_new_size(size_t size);
47
+ binyo_byte_buffer *binyo_buffer_new_prealloc(uint8_t *b, size_t len);
48
+ ssize_t binyo_buffer_write(binyo_byte_buffer *buffer, uint8_t *b, size_t len);
49
+ void binyo_buffer_free_secure(binyo_byte_buffer *buffer);
50
+ void binyo_buffer_free(binyo_byte_buffer *buffer);
51
+
52
+ size_t binyo_buffer_get_bytes_free(binyo_byte_buffer *buffer, uint8_t **out);
53
+
54
+ #endif /* _BINYO_IO_BUFFER_H_ */
@@ -0,0 +1,131 @@
1
+ /*
2
+ * binyo - Fast binary IO for Ruby
3
+ *
4
+ * Copyright (c) 2012-2013
5
+ * Martin Bosslet <martin.bosslet@gmail.com>
6
+ * All rights reserved.
7
+ *
8
+ * Permission is hereby granted, free of charge, to any person obtaining
9
+ * a copy of this software and associated documentation files (the
10
+ * "Software"), to deal in the Software without restriction, including
11
+ * without limitation the rights to use, copy, modify, merge, publish,
12
+ * distribute, sublicense, and/or sell copies of the Software, and to
13
+ * permit persons to whom the Software is furnished to do so, subject to
14
+ * the following conditions:
15
+ *
16
+ * The above copyright notice and this permission notice shall be
17
+ * included in all copies or substantial portions of the Software.
18
+ *
19
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
22
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
23
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
24
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
25
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26
+ */
27
+
28
+ #if !defined(_BINYO_IO_H_)
29
+ #define _BINYO_IO_H_
30
+
31
+ #include "binyo-io-buffer.h"
32
+
33
+ extern ID sBinyo_ID_READ, sBinyo_ID_SEEK, sBinyo_ID_WRITE, sBinyo_ID_CLOSE;
34
+
35
+ extern VALUE sBinyo_ID_SEEK_CUR, sBinyo_ID_SEEK_SET, sBinyo_ID_SEEK_END;
36
+
37
+ #define BINYO_IO_BUF_SIZE 8192
38
+
39
+ #define BINYO_INSTREAM_TYPE_FD 0
40
+ #define BINYO_INSTREAM_TYPE_BYTES 1
41
+ #define BINYO_INSTREAM_TYPE_IO_GENERIC 2
42
+ #define BINYO_INSTREAM_TYPE_SEQ 3
43
+ #define BINYO_INSTREAM_TYPE_CACHE 4
44
+
45
+ #define BINYO_OUTSTREAM_TYPE_FD 10
46
+ #define BINYO_OUTSTREAM_TYPE_BYTES 11
47
+ #define BINYO_OUTSTREAM_TYPE_IO_GENERIC 12
48
+
49
+ typedef struct binyo_instream_interface_st binyo_instream_interface;
50
+ typedef struct binyo_outstream_interface_st binyo_outstream_interface;
51
+
52
+ typedef struct binyo_instream_st {
53
+ binyo_instream_interface *methods;
54
+ } binyo_instream;
55
+
56
+ typedef struct binyo_out_stream_st {
57
+ binyo_outstream_interface *methods;
58
+ } binyo_outstream;
59
+
60
+ struct binyo_instream_interface_st {
61
+ int type;
62
+
63
+ ssize_t (*read)(binyo_instream*, uint8_t*, size_t);
64
+ int (*rb_read)(binyo_instream*, VALUE, VALUE, VALUE*);
65
+ ssize_t (*gets)(binyo_instream*, char *, size_t);
66
+ int (*seek)(binyo_instream*, off_t, int);
67
+ void (*mark)(binyo_instream*);
68
+ void (*free)(binyo_instream*);
69
+ };
70
+
71
+ struct binyo_outstream_interface_st {
72
+ int type;
73
+
74
+ ssize_t (*write)(binyo_outstream*, uint8_t *buf, size_t);
75
+ int (*rb_write)(binyo_outstream*, VALUE, VALUE*);
76
+ void (*mark)(binyo_outstream*);
77
+ void (*free)(binyo_outstream*);
78
+ };
79
+
80
+ #define binyo_safe_cast_stream(out, in, t, ptype, stype) \
81
+ do { \
82
+ if (!(in)) \
83
+ rb_raise(rb_eRuntimeError, "Uninitialized stream."); \
84
+ if (((stype *) (in))->methods->type == (t)) { \
85
+ out = (ptype *) in; \
86
+ } \
87
+ else { \
88
+ int errt = ((stype *) (in))->methods->type; \
89
+ rb_raise(rb_eArgError, "Unknown type: %d", errt); \
90
+ } \
91
+ } while (0) \
92
+
93
+ #define binyo_safe_cast_outstream(out, in, type, ptrtype) binyo_safe_cast_stream((out), (in), (type), ptrtype, binyo_outstream)
94
+ #define binyo_safe_cast_instream(out, in, type, ptrtype) binyo_safe_cast_stream((out), (in), (type), ptrtype, binyo_instream)
95
+
96
+ ssize_t binyo_instream_read(binyo_instream *in, uint8_t *buf, size_t len);
97
+ int binyo_instream_rb_read(binyo_instream *in, VALUE vlen, VALUE vbuf, VALUE *out);
98
+ ssize_t binyo_instream_gets(binyo_instream *in, char *line, size_t len);
99
+ int binyo_instream_seek(binyo_instream *in, off_t offset, int whence);
100
+ #define binyo_instream_skip(in, n) binyo_instream_seek((in), (n), SEEK_CUR)
101
+ void binyo_instream_mark(binyo_instream *in);
102
+ void binyo_instream_free(binyo_instream *in);
103
+
104
+ binyo_instream *binyo_instream_new_fd(int fd);
105
+ binyo_instream *binyo_instream_new_fd_io(VALUE io);
106
+ binyo_instream *binyo_instream_new_bytes(uint8_t *bytes, size_t len);
107
+ binyo_instream *binyo_instream_new_io_generic(VALUE io);
108
+ binyo_instream *binyo_instream_new_value(VALUE value);
109
+ binyo_instream *binyo_instream_new_seq(binyo_instream *in1, binyo_instream *in2);
110
+ binyo_instream *binyo_instream_new_seq_n(int num, binyo_instream *in1, binyo_instream *in2, ...);
111
+ binyo_instream *binyo_instream_new_cache(binyo_instream *original);
112
+ void binyo_instream_cache_free_wrapper(binyo_instream *instream);
113
+ size_t binyo_instream_cache_get_bytes(binyo_instream *in, uint8_t **out);
114
+
115
+ ssize_t binyo_outstream_write(binyo_outstream *out, uint8_t *buf, size_t len);
116
+ int binyo_outstream_rb_write(binyo_outstream *out, VALUE vbuf, VALUE *ret);
117
+ void binyo_outstream_mark(binyo_outstream *in);
118
+ void binyo_outstream_free(binyo_outstream *out);
119
+
120
+ size_t binyo_outstream_bytes_get_bytes_free(binyo_outstream *outstream, uint8_t **bytes);
121
+
122
+ binyo_outstream *binyo_outstream_new_fd(int fd);
123
+ binyo_outstream *binyo_outstream_new_fd_io(VALUE io);
124
+ binyo_outstream *binyo_outstream_new_bytes(void);
125
+ binyo_outstream *binyo_outstream_new_bytes_size(size_t size);
126
+ binyo_outstream *binyo_outstream_new_bytes_prealloc(uint8_t *b, size_t len);
127
+ binyo_outstream *binyo_outstream_new_io_generic(VALUE io);
128
+ binyo_outstream *binyo_outstream_new_value(VALUE value);
129
+
130
+ #endif /* _BINYO_IO_H_ */
131
+
@@ -0,0 +1,44 @@
1
+ /*
2
+ * binyo - Fast binary IO for Ruby
3
+ *
4
+ * Copyright (c) 2012-2013
5
+ * Martin Bosslet <martin.bosslet@gmail.com>
6
+ * All rights reserved.
7
+ *
8
+ * Permission is hereby granted, free of charge, to any person obtaining
9
+ * a copy of this software and associated documentation files (the
10
+ * "Software"), to deal in the Software without restriction, including
11
+ * without limitation the rights to use, copy, modify, merge, publish,
12
+ * distribute, sublicense, and/or sell copies of the Software, and to
13
+ * permit persons to whom the Software is furnished to do so, subject to
14
+ * the following conditions:
15
+ *
16
+ * The above copyright notice and this permission notice shall be
17
+ * included in all copies or substantial portions of the Software.
18
+ *
19
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
22
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
23
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
24
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
25
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26
+ */
27
+
28
+ #ifndef _BINYO_MEM_H_
29
+ #define _BINYO_MEM_H_
30
+
31
+ /* memory utilities */
32
+ #define BINYO_ALLOC(type) ((type *)binyo_alloc(sizeof(type)))
33
+ #define BINYO_ALLOC_N(type, n) ((type *)binyo_alloc_n((n), sizeof(type)))
34
+ #define BINYO_ALLOCA_N(type, n) ((type *)alloca(sizeof(type) * (n)))
35
+ #define BINYO_REALLOC_N(ptr, type, n) ((ptr)=(type *)binyo_realloc_n((void *)(ptr), (n), sizeof(type)))
36
+ #define BINYO_FREE binyo_free
37
+
38
+ void *binyo_alloc(size_t size);
39
+ void *binyo_alloc_n(size_t n, size_t size);
40
+ void *binyo_realloc_n(void *ptr, size_t n, size_t size);
41
+ void binyo_free(void *ptr);
42
+
43
+ #endif /* _BINYO_MEM_H_ */
44
+
@@ -0,0 +1,36 @@
1
+ /*
2
+ * binyo - Fast binary IO for Ruby
3
+ *
4
+ * Copyright (c) 2012-2013
5
+ * Martin Bosslet <martin.bosslet@gmail.com>
6
+ * All rights reserved.
7
+ *
8
+ * Permission is hereby granted, free of charge, to any person obtaining
9
+ * a copy of this software and associated documentation files (the
10
+ * "Software"), to deal in the Software without restriction, including
11
+ * without limitation the rights to use, copy, modify, merge, publish,
12
+ * distribute, sublicense, and/or sell copies of the Software, and to
13
+ * permit persons to whom the Software is furnished to do so, subject to
14
+ * the following conditions:
15
+ *
16
+ * The above copyright notice and this permission notice shall be
17
+ * included in all copies or substantial portions of the Software.
18
+ *
19
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
22
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
23
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
24
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
25
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26
+ */
27
+
28
+ #ifndef _BINYO_MISSING_H_
29
+ #define _BINYO_MISSING_H_
30
+
31
+ #ifndef HAVE_RB_IO_CHECK_BYTE_READABLE
32
+ #define rb_io_check_byte_readable(fptr) rb_io_check_readable(fptr)
33
+ #endif
34
+
35
+ #endif /* BINYO_MISSING_H */
36
+
@@ -0,0 +1,96 @@
1
+ /*
2
+ * binyo - Fast binary IO for Ruby
3
+ *
4
+ * Copyright (c) 2012-2013
5
+ * Martin Bosslet <martin.bosslet@gmail.com>
6
+ * All rights reserved.
7
+ *
8
+ * Permission is hereby granted, free of charge, to any person obtaining
9
+ * a copy of this software and associated documentation files (the
10
+ * "Software"), to deal in the Software without restriction, including
11
+ * without limitation the rights to use, copy, modify, merge, publish,
12
+ * distribute, sublicense, and/or sell copies of the Software, and to
13
+ * permit persons to whom the Software is furnished to do so, subject to
14
+ * the following conditions:
15
+ *
16
+ * The above copyright notice and this permission notice shall be
17
+ * included in all copies or substantial portions of the Software.
18
+ *
19
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
22
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
23
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
24
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
25
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26
+ */
27
+
28
+ #include "binyo.h"
29
+
30
+ VALUE mBinyo;
31
+
32
+ VALUE eBinyoError;
33
+
34
+
35
+ void *
36
+ binyo_alloc(size_t size)
37
+ {
38
+ void *mem;
39
+
40
+ if (!(mem = malloc(size)))
41
+ rb_memerror();
42
+ return mem;
43
+ }
44
+
45
+ void *
46
+ binyo_alloc_n(size_t n, size_t size)
47
+ {
48
+ void *mem;
49
+ size_t target_size;
50
+
51
+ if (n > 0 && n > SIZE_MAX / size)
52
+ rb_raise(rb_eArgError, "Malloc size too large");
53
+ target_size = n * size;
54
+ if (!(mem = malloc(target_size)))
55
+ rb_memerror();
56
+ return mem;
57
+ }
58
+
59
+ void *
60
+ binyo_realloc_n(void *ptr, size_t n, size_t size)
61
+ {
62
+ void *mem;
63
+ size_t target_size;
64
+
65
+ if (!ptr)
66
+ rb_raise(rb_eArgError, "Realloc pointer is NULL");
67
+ if (n > 0 && n > SIZE_MAX / size)
68
+ rb_raise(rb_eArgError, "Realloc size too large");
69
+ target_size = n * size;
70
+ mem = realloc(ptr, target_size);
71
+ if (!mem) {
72
+ free(ptr);
73
+ rb_memerror();
74
+ }
75
+ return mem;
76
+ }
77
+
78
+ void
79
+ binyo_free(void *ptr)
80
+ {
81
+ if (ptr)
82
+ free(ptr);
83
+ }
84
+
85
+ void
86
+ Init_binyo(void)
87
+ {
88
+ mBinyo = rb_define_module("Binyo");
89
+
90
+ eBinyoError = rb_define_class_under(mBinyo, "BinyoError", rb_eStandardError);
91
+
92
+ Init_binyo_io();
93
+ Init_binyo_bytelist();
94
+ Init_binyo_byte();
95
+ }
96
+