lulu 0.0.3 → 0.0.4
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.
- checksums.yaml +8 -8
- data/ext/lulu/lulu.c +32 -28
- data/ext/lulu/marker.h +19 -0
- data/ext/lulu/merger.h +2 -0
- data/ext/lulu/namespace.h +14 -0
- data/ext/lulu/pq.h +11 -0
- data/ext/lulu/qt.h +15 -0
- data/ext/lulu/test.h +4 -0
- data/ext/lulu/utility.h +6 -0
- data/lib/lulu/version.rb +1 -1
- data/spec/lib/marker_list_spec.rb +5 -8
- data/spec/spec_helper.rb +10 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
OTEyMjAyN2MwMjQ5MjJhMDEwZjQzMjRmMWRhYTRiYzUwYjZkZWZkOA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NWM2MzllZGU0MDJhMjMxYzg0NTUxMWMyYmNlMmUyMDc5MGZmZDgxNQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NjNjYjJlODhiYTFlMzA4ZDRlOTdhNTk0MjZlNTU5NjI4NTE4MDRjMWI5NDg4
|
10
|
+
MzY4M2NiNDEyYTliZDdmN2Y3MjkzM2ZmZmJjMmZkOGIxNmNjMWY1YTkyMTgx
|
11
|
+
YjA0Y2Q0MGRlN2M2MGRkOTdhOTFlZWEzNWMyOTEwNGFiNGQ1M2I=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
OTkxMjhlMjcxZjNkMzUyYzEyNTZlZTkyZjZkNzIwOTAzNmNmYzRjMmZmNTY4
|
14
|
+
YjM5YjkyNDM0N2JjMzMwZWZmYjVhY2E5YWYxNzY2NmVhNWZjM2E3MDE1YWEw
|
15
|
+
NTg1Njc0ZTQxYjdiZDNlNTFiMDE1OWUxOWUzMDY3YzdhZTlkMGI=
|
data/ext/lulu/lulu.c
CHANGED
@@ -31,29 +31,29 @@ typedef struct marker_list_s {
|
|
31
31
|
#define MARKER_LIST_DECL(Name) MARKER_LIST Name[1]; init_marker_list(Name)
|
32
32
|
#define ml_set_marker_list_info(L, Kind, Scale) mr_info_set((L)->info, (Kind), (Scale))
|
33
33
|
|
34
|
-
void init_marker_list(MARKER_LIST *list) {
|
34
|
+
static void init_marker_list(MARKER_LIST *list) {
|
35
35
|
mr_info_init(list->info);
|
36
36
|
list->markers = NULL;
|
37
37
|
list->size = list->max_size = 0;
|
38
38
|
}
|
39
39
|
|
40
|
-
MARKER_LIST *new_marker_list(void) {
|
40
|
+
static MARKER_LIST *new_marker_list(void) {
|
41
41
|
NewDecl(MARKER_LIST, list);
|
42
42
|
init_marker_list(list);
|
43
43
|
return list;
|
44
44
|
}
|
45
45
|
|
46
|
-
void clear_marker_list(MARKER_LIST *list) {
|
46
|
+
static void clear_marker_list(MARKER_LIST *list) {
|
47
47
|
Free(list->markers);
|
48
48
|
init_marker_list(list);
|
49
49
|
}
|
50
50
|
|
51
|
-
void free_marker_list(MARKER_LIST *list) {
|
51
|
+
static void free_marker_list(MARKER_LIST *list) {
|
52
52
|
clear_marker_list(list);
|
53
53
|
Free(list);
|
54
54
|
}
|
55
55
|
|
56
|
-
void add_marker(MARKER_LIST *list, MARKER_COORD x, MARKER_COORD y, MARKER_SIZE size) {
|
56
|
+
static void add_marker(MARKER_LIST *list, MARKER_COORD x, MARKER_COORD y, MARKER_SIZE size) {
|
57
57
|
if (list->size >= list->max_size) {
|
58
58
|
list->max_size = 4 + 2 * list->max_size;
|
59
59
|
RenewArray(list->markers, list->max_size);
|
@@ -62,7 +62,7 @@ void add_marker(MARKER_LIST *list, MARKER_COORD x, MARKER_COORD y, MARKER_SIZE s
|
|
62
62
|
mr_set(list->info, marker, x, y, size);
|
63
63
|
}
|
64
64
|
|
65
|
-
void ensure_headroom(MARKER_LIST *list) {
|
65
|
+
static void ensure_headroom(MARKER_LIST *list) {
|
66
66
|
int needed_size = 2 * list->size - 1;
|
67
67
|
if (list->max_size < needed_size) {
|
68
68
|
list->max_size = needed_size;
|
@@ -70,7 +70,7 @@ void ensure_headroom(MARKER_LIST *list) {
|
|
70
70
|
}
|
71
71
|
}
|
72
72
|
|
73
|
-
void compress(MARKER_LIST *list) {
|
73
|
+
static void compress(MARKER_LIST *list) {
|
74
74
|
int dst = 0;
|
75
75
|
for (int src = 0; src < list->size; src++)
|
76
76
|
if (!mr_deleted_p(list->markers + src)) {
|
@@ -84,24 +84,24 @@ void compress(MARKER_LIST *list) {
|
|
84
84
|
|
85
85
|
// -------- Ruby API implementation --------------------------------------------
|
86
86
|
|
87
|
-
static void
|
87
|
+
static void lulu_rb_api_free_marker_list(void *list) {
|
88
88
|
free_marker_list(list);
|
89
89
|
}
|
90
90
|
|
91
|
-
static VALUE
|
91
|
+
static VALUE lulu_rb_api_new_marker_list(VALUE klass) {
|
92
92
|
MARKER_LIST *list = new_marker_list();
|
93
|
-
return Data_Wrap_Struct(klass, 0,
|
93
|
+
return Data_Wrap_Struct(klass, 0, lulu_rb_api_free_marker_list, list);
|
94
94
|
}
|
95
95
|
|
96
96
|
#define MARKER_LIST_FOR_VALUE_DECL(Var) MARKER_LIST *Var; Data_Get_Struct(Var ## _value, MARKER_LIST, Var)
|
97
97
|
|
98
|
-
static VALUE
|
98
|
+
static VALUE lulu_rb_api_initialize_copy(VALUE dst_value, VALUE src_value)
|
99
99
|
#define ARGC_initialize_copy 1
|
100
100
|
{
|
101
101
|
if (dst_value == src_value)
|
102
102
|
return src_value;
|
103
103
|
|
104
|
-
if (TYPE(src_value) != T_DATA || RDATA(src_value)->dfree != (RUBY_DATA_FUNC)
|
104
|
+
if (TYPE(src_value) != T_DATA || RDATA(src_value)->dfree != (RUBY_DATA_FUNC)lulu_rb_api_free_marker_list)
|
105
105
|
rb_raise(rb_eTypeError, "type mismatch (copy_marker_list)");
|
106
106
|
|
107
107
|
MARKER_LIST_FOR_VALUE_DECL(src);
|
@@ -115,7 +115,7 @@ static VALUE rb_api_initialize_copy(VALUE dst_value, VALUE src_value)
|
|
115
115
|
return dst_value;
|
116
116
|
}
|
117
117
|
|
118
|
-
static VALUE
|
118
|
+
static VALUE lulu_rb_api_clear(VALUE self_value)
|
119
119
|
#define ARGC_clear 0
|
120
120
|
{
|
121
121
|
MARKER_LIST_FOR_VALUE_DECL(self);
|
@@ -123,7 +123,7 @@ static VALUE rb_api_clear(VALUE self_value)
|
|
123
123
|
return self_value;
|
124
124
|
}
|
125
125
|
|
126
|
-
static VALUE
|
126
|
+
static VALUE lulu_rb_api_set_info(VALUE self_value, VALUE kind_value, VALUE scale_value)
|
127
127
|
#define ARGC_set_info 2
|
128
128
|
{
|
129
129
|
MARKER_LIST_FOR_VALUE_DECL(self);
|
@@ -144,7 +144,7 @@ static VALUE rb_api_set_info(VALUE self_value, VALUE kind_value, VALUE scale_val
|
|
144
144
|
return self_value;
|
145
145
|
}
|
146
146
|
|
147
|
-
static VALUE
|
147
|
+
static VALUE lulu_rb_api_add(VALUE self_value, VALUE x_value, VALUE y_value, VALUE size_value)
|
148
148
|
#define ARGC_add 3
|
149
149
|
{
|
150
150
|
MARKER_LIST_FOR_VALUE_DECL(self);
|
@@ -152,14 +152,14 @@ static VALUE rb_api_add(VALUE self_value, VALUE x_value, VALUE y_value, VALUE si
|
|
152
152
|
return INT2FIX(self->size);
|
153
153
|
}
|
154
154
|
|
155
|
-
static VALUE
|
155
|
+
static VALUE lulu_rb_api_length(VALUE self_value)
|
156
156
|
#define ARGC_length 0
|
157
157
|
{
|
158
158
|
MARKER_LIST_FOR_VALUE_DECL(self);
|
159
159
|
return INT2FIX(self->size);
|
160
160
|
}
|
161
161
|
|
162
|
-
static VALUE
|
162
|
+
static VALUE lulu_rb_api_marker(VALUE self_value, VALUE index)
|
163
163
|
#define ARGC_marker 1
|
164
164
|
{
|
165
165
|
MARKER_LIST_FOR_VALUE_DECL(self);
|
@@ -175,7 +175,7 @@ static VALUE rb_api_marker(VALUE self_value, VALUE index)
|
|
175
175
|
return Qnil;
|
176
176
|
}
|
177
177
|
|
178
|
-
static VALUE
|
178
|
+
static VALUE lulu_rb_api_parts(VALUE self_value, VALUE index)
|
179
179
|
#define ARGC_parts 1
|
180
180
|
{
|
181
181
|
MARKER_LIST_FOR_VALUE_DECL(self);
|
@@ -197,7 +197,7 @@ static VALUE rb_api_parts(VALUE self_value, VALUE index)
|
|
197
197
|
return Qnil;
|
198
198
|
}
|
199
199
|
|
200
|
-
static VALUE
|
200
|
+
static VALUE lulu_rb_api_deleted(VALUE self_value, VALUE index)
|
201
201
|
#define ARGC_deleted 1
|
202
202
|
{
|
203
203
|
MARKER_LIST_FOR_VALUE_DECL(self);
|
@@ -207,7 +207,7 @@ static VALUE rb_api_deleted(VALUE self_value, VALUE index)
|
|
207
207
|
return Qnil;
|
208
208
|
}
|
209
209
|
|
210
|
-
static VALUE
|
210
|
+
static VALUE lulu_rb_api_compress(VALUE self_value)
|
211
211
|
#define ARGC_compress 0
|
212
212
|
{
|
213
213
|
MARKER_LIST_FOR_VALUE_DECL(self);
|
@@ -215,23 +215,25 @@ static VALUE rb_api_compress(VALUE self_value)
|
|
215
215
|
return INT2FIX(self->size);
|
216
216
|
}
|
217
217
|
|
218
|
-
static VALUE
|
218
|
+
static VALUE lulu_rb_api_merge(VALUE self_value)
|
219
219
|
#define ARGC_merge 0
|
220
220
|
{
|
221
221
|
MARKER_LIST_FOR_VALUE_DECL(self);
|
222
|
-
ensure_headroom(self);
|
223
222
|
compress(self);
|
223
|
+
ensure_headroom(self);
|
224
224
|
self->size = merge_markers_fast(self->info, self->markers, self->size);
|
225
225
|
return INT2FIX(self->size);
|
226
226
|
}
|
227
227
|
|
228
|
-
#define FUNCTION_TABLE_ENTRY(Name) { #Name, RUBY_METHOD_FUNC(
|
228
|
+
#define FUNCTION_TABLE_ENTRY(Name) { #Name, RUBY_METHOD_FUNC(lulu_rb_api_ ## Name), ARGC_ ## Name }
|
229
229
|
|
230
|
-
|
230
|
+
struct ft_entry {
|
231
231
|
const char *name;
|
232
232
|
VALUE (*func)(ANYARGS);
|
233
233
|
int argc;
|
234
|
-
}
|
234
|
+
};
|
235
|
+
|
236
|
+
static struct ft_entry function_table[] = {
|
235
237
|
FUNCTION_TABLE_ENTRY(add),
|
236
238
|
FUNCTION_TABLE_ENTRY(compress),
|
237
239
|
FUNCTION_TABLE_ENTRY(clear),
|
@@ -246,10 +248,12 @@ static struct ft_entry {
|
|
246
248
|
|
247
249
|
#define STRING_CONST_TABLE_ENTRY(Name) { #Name, Name }
|
248
250
|
|
249
|
-
|
251
|
+
struct sct_entry {
|
250
252
|
const char *name;
|
251
253
|
const char *val;
|
252
|
-
}
|
254
|
+
};
|
255
|
+
|
256
|
+
static struct sct_entry string_const_table[] = {
|
253
257
|
STRING_CONST_TABLE_ENTRY(EXT_VERSION)
|
254
258
|
};
|
255
259
|
|
@@ -257,7 +261,7 @@ void Init_lulu(void)
|
|
257
261
|
{
|
258
262
|
VALUE module = rb_define_module("Lulu");
|
259
263
|
VALUE klass = rb_define_class_under(module, "MarkerList", rb_cObject);
|
260
|
-
rb_define_alloc_func(klass,
|
264
|
+
rb_define_alloc_func(klass, lulu_rb_api_new_marker_list);
|
261
265
|
|
262
266
|
for (int i = 0; i < STATIC_ARRAY_SIZE(function_table); i++) {
|
263
267
|
struct ft_entry *e = function_table + i;
|
data/ext/lulu/marker.h
CHANGED
@@ -8,6 +8,8 @@
|
|
8
8
|
#ifndef MARKER_H_
|
9
9
|
#define MARKER_H_
|
10
10
|
|
11
|
+
#include "namespace.h"
|
12
|
+
|
11
13
|
typedef double MARKER_COORD;
|
12
14
|
typedef double MARKER_DISTANCE;
|
13
15
|
/**
|
@@ -57,14 +59,31 @@ typedef struct marker_extent_s {
|
|
57
59
|
#define mr_s(M) ((M)->y - (M)->r)
|
58
60
|
#define mr_n(M) ((M)->y + (M)->r)
|
59
61
|
|
62
|
+
#define mr_init(Marker, NMarkers) NAME(mr_init)(Marker, NMarkers)
|
60
63
|
void mr_init(MARKER *marker, int n_markers);
|
64
|
+
|
65
|
+
#define mr_reset_parts(Marker) NAME(mr_reset_parts)(Marker)
|
61
66
|
void mr_reset_parts(MARKER *marker);
|
67
|
+
|
68
|
+
#define mr_info_init(Info) NAME(mr_info_init)(Info)
|
62
69
|
void mr_info_init(MARKER_INFO *info);
|
70
|
+
|
71
|
+
#define mr_info_set(Info, Kind, Scale) NAME(mr_info_set)(Info, Kind, Scale)
|
63
72
|
void mr_info_set(MARKER_INFO *info, MARKER_KIND kind, MARKER_DISTANCE scale);
|
73
|
+
|
74
|
+
#define mr_set(Info, Marker, X, Y, Size) NAME(mr_set)(Info, Marker, X, Y, Size)
|
64
75
|
void mr_set(MARKER_INFO *info, MARKER *marker, MARKER_COORD x, MARKER_COORD y, MARKER_SIZE size);
|
76
|
+
|
77
|
+
#define mr_merge(Info, Markers, Merged, A, B) NAME(mr_merge)(Info, Markers, Merged, A, B)
|
65
78
|
void mr_merge(MARKER_INFO *info, MARKER *markers, int merged, int a, int b);
|
79
|
+
|
80
|
+
#define mr_distance(Info, A, B) NAME(mr_distance)(Info, A, B)
|
66
81
|
MARKER_DISTANCE mr_distance(MARKER_INFO *info, MARKER *a, MARKER *b);
|
82
|
+
|
83
|
+
#define size_to_radius(Info, Size) NAME(size_to_radius)(Info, Size)
|
67
84
|
MARKER_DISTANCE size_to_radius(MARKER_INFO *info, MARKER_SIZE size);
|
85
|
+
|
86
|
+
#define get_marker_array_extent(A, NMarkers, Ext) NAME(get_marker_array_extent)(A, NMarkers, Ext)
|
68
87
|
void get_marker_array_extent(MARKER *a, int n_markers, MARKER_EXTENT *ext);
|
69
88
|
|
70
89
|
#endif /* MARKER_H_ */
|
data/ext/lulu/merger.h
CHANGED
@@ -8,8 +8,10 @@
|
|
8
8
|
#ifndef MERGER_H_
|
9
9
|
#define MERGER_H_
|
10
10
|
|
11
|
+
#include "namespace.h"
|
11
12
|
#include "marker.h"
|
12
13
|
|
14
|
+
#define merge_markers_fast(Info, Markers, MarkersSize) NAME(merge_markers_fast)(Info, Markers, MarkersSize)
|
13
15
|
int merge_markers_fast(MARKER_INFO *info, MARKER *markers, int markers_size);
|
14
16
|
|
15
17
|
#endif /* MERGER_H_ */
|
data/ext/lulu/pq.h
CHANGED
@@ -8,6 +8,8 @@
|
|
8
8
|
#ifndef PRIORITY_QUEUE_H_
|
9
9
|
#define PRIORITY_QUEUE_H_
|
10
10
|
|
11
|
+
#include "namespace.h"
|
12
|
+
|
11
13
|
typedef double PRIORITY_QUEUE_VALUE;
|
12
14
|
|
13
15
|
typedef struct priority_queue_s {
|
@@ -19,37 +21,46 @@ typedef struct priority_queue_s {
|
|
19
21
|
} PRIORITY_QUEUE;
|
20
22
|
|
21
23
|
// Initialize a newly allocated priority queue structure.
|
24
|
+
#define pq_init(Q) NAME(pq_init)(Q)
|
22
25
|
void pq_init(PRIORITY_QUEUE *q);
|
23
26
|
|
24
27
|
#define PRIORITY_QUEUE_DECL(Q) PRIORITY_QUEUE Q[1]; pq_init(Q)
|
25
28
|
|
26
29
|
// Clear a previously initialized and possibly set up priority queue, returning
|
27
30
|
// it to the initialized state but with all resourced freed.
|
31
|
+
#define pq_clear(Q) NAME(pq_clear)(Q)
|
28
32
|
void pq_clear(PRIORITY_QUEUE *q);
|
29
33
|
|
30
34
|
// Build the queue with given pre-allocated and filled array of values.
|
35
|
+
#define pq_set_up(Q, Values, Size) NAME(pq_set_up)(Q, Values, Size)
|
31
36
|
void pq_set_up(PRIORITY_QUEUE *q, PRIORITY_QUEUE_VALUE *values, int size);
|
32
37
|
|
33
38
|
// Build the queue with given pre-allocated and filled array of values
|
34
39
|
// and given heap indices. Note the indices are owned by the heap
|
35
40
|
// after set up and will be freed with the heap.
|
41
|
+
#define pq_set_up_heap(Q, Heap, Size, Values, MaxSize) NAME(pq_set_up_heap)(Q, Heap, Size, Values, MaxSize)
|
36
42
|
void pq_set_up_heap(PRIORITY_QUEUE *q,
|
37
43
|
int *heap, int size,
|
38
44
|
PRIORITY_QUEUE_VALUE *values, int max_size);
|
39
45
|
|
40
46
|
// Return the index of the minimum value on the queue.
|
47
|
+
#define pq_peek_min(Q) NAME(pq_peek_min)(Q)
|
41
48
|
int pq_peek_min(PRIORITY_QUEUE *q);
|
42
49
|
|
43
50
|
// Remove and return the index of the minimum value on the queue.
|
51
|
+
#define pq_get_min(Q) NAME(pq_get_min)(Q)
|
44
52
|
int pq_get_min(PRIORITY_QUEUE *q);
|
45
53
|
|
46
54
|
// Update the queue given that the value at index i has changed.
|
55
|
+
#define pq_update(Q, I) NAME(pq_update)(Q, I)
|
47
56
|
void pq_update(PRIORITY_QUEUE *q, int i);
|
48
57
|
|
49
58
|
// Add a new value with index i into the queue.
|
59
|
+
#define pq_add(Q, I) NAME(pq_add)(Q, I)
|
50
60
|
void pq_add(PRIORITY_QUEUE *q, int i);
|
51
61
|
|
52
62
|
// Delete index i from the heap, making the corresponding key an orphan.
|
63
|
+
#define pq_delete(Q, I) NAME(pq_delete)(Q, I)
|
53
64
|
void pq_delete(PRIORITY_QUEUE *q, int i);
|
54
65
|
|
55
66
|
// Return an array containing indices currently in the heap.
|
data/ext/lulu/qt.h
CHANGED
@@ -8,6 +8,7 @@
|
|
8
8
|
#ifndef QT_H_
|
9
9
|
#define QT_H_
|
10
10
|
|
11
|
+
#include "namespace.h"
|
11
12
|
#include "marker.h"
|
12
13
|
|
13
14
|
typedef struct node_s {
|
@@ -46,13 +47,27 @@ typedef struct quadtree_s {
|
|
46
47
|
|
47
48
|
#define QUADTREE_DECL(Name) QUADTREE Name[1]; qt_init(Name)
|
48
49
|
|
50
|
+
#define qt_init(T) NAME(qt_init)(T)
|
49
51
|
void qt_init(QUADTREE *qt);
|
52
|
+
|
53
|
+
#define qt_setup(T, MaxDepth, X, Y, W, H, Info) NAME(qt_setup)(T, MaxDepth, X, Y, W, H, Info)
|
50
54
|
void qt_setup(QUADTREE *qt, int max_depth,
|
51
55
|
MARKER_COORD x, MARKER_COORD y, MARKER_DISTANCE w, MARKER_DISTANCE h,
|
52
56
|
MARKER_INFO *info);
|
57
|
+
|
58
|
+
#define qt_clear(T) NAME(qt_clear)(T)
|
59
|
+
void qt_clear(QUADTREE *qt);
|
60
|
+
|
61
|
+
#define qt_insert(T, Marker) NAME(qt_insert)(T, Marker)
|
53
62
|
void qt_insert(QUADTREE *qt, MARKER *marker);
|
63
|
+
|
64
|
+
#define qt_delete(T, Marker) NAME(qt_delete)(T, Marker)
|
54
65
|
void qt_delete(QUADTREE *qt, MARKER *marker);
|
66
|
+
|
67
|
+
#define qt_nearest(T, Marker) NAME(qt_nearest)(T, Marker)
|
55
68
|
MARKER *qt_nearest(QUADTREE *qt, MARKER *marker);
|
69
|
+
|
70
|
+
#define qt_nearest_wrt(Markers, T, A) NAME(qt_nearest_wrt)(Markers, T, A)
|
56
71
|
int qt_nearest_wrt(MARKER *markers, QUADTREE *qt, int a);
|
57
72
|
|
58
73
|
#endif /* QT_H_ */
|
data/ext/lulu/test.h
CHANGED
@@ -8,6 +8,8 @@
|
|
8
8
|
#ifndef TEST_H_
|
9
9
|
#define TEST_H_
|
10
10
|
|
11
|
+
#ifdef UNIT_TESTS
|
12
|
+
|
11
13
|
#include "marker.h"
|
12
14
|
|
13
15
|
int emit_markers(const char *name, MARKER *markers, int n_markers);
|
@@ -22,4 +24,6 @@ int qt_test(int size);
|
|
22
24
|
int pq_test(int size);
|
23
25
|
int merge_test(int test_markers_size);
|
24
26
|
|
27
|
+
#endif
|
28
|
+
|
25
29
|
#endif /* TEST_H_ */
|
data/ext/lulu/utility.h
CHANGED
@@ -8,6 +8,8 @@
|
|
8
8
|
#ifndef UTILITY_H_
|
9
9
|
#define UTILITY_H_
|
10
10
|
|
11
|
+
#include "namespace.h"
|
12
|
+
|
11
13
|
#define STATIC_ARRAY_SIZE(A) ((int)(sizeof A / sizeof A[0]))
|
12
14
|
|
13
15
|
#ifdef LULU_STD_C
|
@@ -30,7 +32,10 @@
|
|
30
32
|
Ptr = NULL; \
|
31
33
|
} while (0)
|
32
34
|
|
35
|
+
#define safe_malloc(Size, File, Line) NAME(safe_malloc)(Size, File, Line)
|
33
36
|
void *safe_malloc(size_t size, const char *file, int line);
|
37
|
+
|
38
|
+
#define safe_realloc(P, Size, File, Line) NAME(safe_realloc)(P, Size, File, Line)
|
34
39
|
void *safe_realloc(void *p, size_t size, const char *file, int line);
|
35
40
|
|
36
41
|
#endif
|
@@ -72,6 +77,7 @@ void trace(const char *fmt, ...);
|
|
72
77
|
#define TRACE(Args)
|
73
78
|
#endif
|
74
79
|
|
80
|
+
#define high_bit_position(N) NAME(high_bit_position)(N)
|
75
81
|
int high_bit_position(unsigned n);
|
76
82
|
|
77
83
|
#endif /* UTILITY_H_ */
|
data/lib/lulu/version.rb
CHANGED
@@ -3,14 +3,7 @@ require 'spec_helper'
|
|
3
3
|
# Test the Lulu API.
|
4
4
|
describe Lulu::MarkerList do
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
let(:list) do
|
9
|
-
list = Lulu::MarkerList.new
|
10
|
-
srand(42)
|
11
|
-
TEST_SIZE.times{ |n| list.add(Random.rand(1000), Random.rand(1000), Random.rand(100)) }
|
12
|
-
list
|
13
|
-
end
|
6
|
+
let(:list) { new_marker_list }
|
14
7
|
|
15
8
|
it 'should have length matching number of markers added' do
|
16
9
|
list.length.should == TEST_SIZE
|
@@ -36,4 +29,8 @@ describe Lulu::MarkerList do
|
|
36
29
|
n.should == list.compress
|
37
30
|
end
|
38
31
|
|
32
|
+
it 'should perform fine over multiple runs with unit increases in input length to provoke memory bugs' do
|
33
|
+
1000.times { |i| new_marker_list(10000 + i).merge }
|
34
|
+
end
|
35
|
+
|
39
36
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lulu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gene Ressler
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-05-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -96,6 +96,7 @@ files:
|
|
96
96
|
- ext/lulu/marker.h
|
97
97
|
- ext/lulu/merger.c
|
98
98
|
- ext/lulu/merger.h
|
99
|
+
- ext/lulu/namespace.h
|
99
100
|
- ext/lulu/pq.c
|
100
101
|
- ext/lulu/pq.h
|
101
102
|
- ext/lulu/qt.c
|