animehunter-mongo_ext 0.4 → 0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/ext/cbson/cbson.c +9 -17
- data/mongo-extensions.gemspec +1 -1
- metadata +1 -1
data/ext/cbson/cbson.c
CHANGED
|
@@ -63,26 +63,19 @@ static VALUE OrderedHash;
|
|
|
63
63
|
#define EXTENDED RE_OPTION_EXTENDED
|
|
64
64
|
#endif
|
|
65
65
|
|
|
66
|
-
/* TODO we ought to check that the
|
|
66
|
+
/* TODO we ought to check that the snprintf was successful
|
|
67
67
|
* and raise an exception if not. */
|
|
68
68
|
#ifdef _MSC_VER
|
|
69
|
-
#define INT2STRING(buffer, i)
|
|
70
|
-
{
|
|
71
|
-
|
|
72
|
-
*buffer = malloc(vslength); \
|
|
73
|
-
_snprintf(*buffer, vslength, "%d", i); \
|
|
74
|
-
}
|
|
75
|
-
#elif defined(__MINGW32__)
|
|
76
|
-
#define INT2STRING(buffer, i) \
|
|
77
|
-
{ \
|
|
78
|
-
int vslength = log10(i) + 2; \
|
|
79
|
-
*buffer = malloc(vslength); \
|
|
80
|
-
_snprintf(*buffer, vslength, "%d", i); \
|
|
69
|
+
#define INT2STRING(buffer, len, i) \
|
|
70
|
+
{ \
|
|
71
|
+
_snprintf(buffer, len, "%d", i); \
|
|
81
72
|
}
|
|
82
73
|
#else
|
|
83
|
-
#define INT2STRING(buffer, i)
|
|
74
|
+
#define INT2STRING(buffer, len, i) snprintf(buffer, len, "%d", i);
|
|
84
75
|
#endif
|
|
85
76
|
|
|
77
|
+
#define I2S_BUFFER_SIZE 32
|
|
78
|
+
|
|
86
79
|
// this sucks too.
|
|
87
80
|
#ifndef RREGEXP_SRC_PTR
|
|
88
81
|
#define RREGEXP_SRC_PTR(r) RREGEXP(r)->str
|
|
@@ -256,6 +249,7 @@ static int write_element_allow_id(VALUE key, VALUE value, VALUE extra, int allow
|
|
|
256
249
|
}
|
|
257
250
|
case T_ARRAY:
|
|
258
251
|
{
|
|
252
|
+
char name[I2S_BUFFER_SIZE];
|
|
259
253
|
int start_position, length_location, items, i, obj_length;
|
|
260
254
|
VALUE* values;
|
|
261
255
|
|
|
@@ -268,12 +262,10 @@ static int write_element_allow_id(VALUE key, VALUE value, VALUE extra, int allow
|
|
|
268
262
|
items = RARRAY_LEN(value);
|
|
269
263
|
values = RARRAY_PTR(value);
|
|
270
264
|
for(i = 0; i < items; i++) {
|
|
271
|
-
char* name;
|
|
272
265
|
VALUE key;
|
|
273
|
-
INT2STRING(
|
|
266
|
+
INT2STRING(name,I2S_BUFFER_SIZE,i);
|
|
274
267
|
key = rb_str_new2(name);
|
|
275
268
|
write_element(key, values[i], pack_extra(buffer, check_keys));
|
|
276
|
-
free(name);
|
|
277
269
|
}
|
|
278
270
|
|
|
279
271
|
// write null byte and fill in length
|
data/mongo-extensions.gemspec
CHANGED
|
@@ -7,7 +7,7 @@ TEST_FILES = []
|
|
|
7
7
|
|
|
8
8
|
Gem::Specification.new do |s|
|
|
9
9
|
s.name = 'mongo_ext'
|
|
10
|
-
s.version = '0.
|
|
10
|
+
s.version = '0.5'
|
|
11
11
|
s.platform = Gem::Platform::RUBY
|
|
12
12
|
s.summary = 'C extensions for the MongoDB Ruby driver'
|
|
13
13
|
s.description = 'C extensions to accelerate the MondoDB Ruby driver. For more information about Mongo, see http://www.mongodb.org.'
|