isomorfeus-ferret 0.12.7 → 0.13.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (164) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +101 -19
  3. data/README.md +54 -1
  4. data/ext/isomorfeus_ferret_ext/bm_bitvector.c +22 -30
  5. data/ext/isomorfeus_ferret_ext/bm_hash.c +6 -12
  6. data/ext/isomorfeus_ferret_ext/bm_micro_string.c +3 -6
  7. data/ext/isomorfeus_ferret_ext/bm_store.c +11 -22
  8. data/ext/isomorfeus_ferret_ext/brotli_common_dictionary.c +1 -1
  9. data/ext/isomorfeus_ferret_ext/brotli_dec_decode.c +1 -1
  10. data/ext/isomorfeus_ferret_ext/bzip_blocksort.c +1094 -0
  11. data/ext/isomorfeus_ferret_ext/bzip_huffman.c +205 -0
  12. data/ext/isomorfeus_ferret_ext/bzlib.c +1572 -0
  13. data/ext/isomorfeus_ferret_ext/bzlib.h +282 -0
  14. data/ext/isomorfeus_ferret_ext/bzlib_compress.c +672 -0
  15. data/ext/isomorfeus_ferret_ext/bzlib_crctable.c +104 -0
  16. data/ext/isomorfeus_ferret_ext/bzlib_decompress.c +652 -0
  17. data/ext/isomorfeus_ferret_ext/bzlib_private.h +509 -0
  18. data/ext/isomorfeus_ferret_ext/bzlib_randtable.c +84 -0
  19. data/ext/isomorfeus_ferret_ext/fio_tmpfile.h +53 -53
  20. data/ext/isomorfeus_ferret_ext/frb_analysis.c +785 -1192
  21. data/ext/isomorfeus_ferret_ext/frb_index.c +492 -474
  22. data/ext/isomorfeus_ferret_ext/frb_qparser.c +48 -60
  23. data/ext/isomorfeus_ferret_ext/frb_search.c +1520 -1002
  24. data/ext/isomorfeus_ferret_ext/frb_store.c +96 -96
  25. data/ext/isomorfeus_ferret_ext/frb_threading.h +0 -1
  26. data/ext/isomorfeus_ferret_ext/frb_utils.c +147 -196
  27. data/ext/isomorfeus_ferret_ext/frt_analysis.c +695 -1090
  28. data/ext/isomorfeus_ferret_ext/frt_analysis.h +174 -170
  29. data/ext/isomorfeus_ferret_ext/frt_array.c +2 -4
  30. data/ext/isomorfeus_ferret_ext/frt_bitvector.c +9 -16
  31. data/ext/isomorfeus_ferret_ext/frt_bitvector.h +32 -81
  32. data/ext/isomorfeus_ferret_ext/frt_document.c +15 -20
  33. data/ext/isomorfeus_ferret_ext/frt_document.h +10 -10
  34. data/ext/isomorfeus_ferret_ext/frt_except.c +5 -12
  35. data/ext/isomorfeus_ferret_ext/frt_field_index.c +3 -3
  36. data/ext/isomorfeus_ferret_ext/frt_field_index.h +6 -7
  37. data/ext/isomorfeus_ferret_ext/frt_filter.c +35 -46
  38. data/ext/isomorfeus_ferret_ext/frt_fs_store.c +1 -0
  39. data/ext/isomorfeus_ferret_ext/frt_global.c +105 -63
  40. data/ext/isomorfeus_ferret_ext/frt_global.h +7 -3
  41. data/ext/isomorfeus_ferret_ext/frt_hash.c +1 -2
  42. data/ext/isomorfeus_ferret_ext/frt_ind.c +32 -35
  43. data/ext/isomorfeus_ferret_ext/frt_ind.h +9 -9
  44. data/ext/isomorfeus_ferret_ext/frt_index.c +580 -399
  45. data/ext/isomorfeus_ferret_ext/frt_index.h +272 -291
  46. data/ext/isomorfeus_ferret_ext/frt_mempool.c +1 -2
  47. data/ext/isomorfeus_ferret_ext/frt_multimapper.c +4 -7
  48. data/ext/isomorfeus_ferret_ext/frt_q_boolean.c +67 -91
  49. data/ext/isomorfeus_ferret_ext/frt_q_const_score.c +35 -38
  50. data/ext/isomorfeus_ferret_ext/frt_q_filtered_query.c +53 -72
  51. data/ext/isomorfeus_ferret_ext/frt_q_fuzzy.c +25 -32
  52. data/ext/isomorfeus_ferret_ext/frt_q_match_all.c +21 -23
  53. data/ext/isomorfeus_ferret_ext/frt_q_multi_term.c +66 -103
  54. data/ext/isomorfeus_ferret_ext/frt_q_parser.c +207 -195
  55. data/ext/isomorfeus_ferret_ext/frt_q_phrase.c +20 -16
  56. data/ext/isomorfeus_ferret_ext/frt_q_prefix.c +17 -14
  57. data/ext/isomorfeus_ferret_ext/frt_q_range.c +102 -131
  58. data/ext/isomorfeus_ferret_ext/frt_q_span.c +179 -178
  59. data/ext/isomorfeus_ferret_ext/frt_q_term.c +47 -60
  60. data/ext/isomorfeus_ferret_ext/frt_q_wildcard.c +18 -16
  61. data/ext/isomorfeus_ferret_ext/frt_ram_store.c +45 -84
  62. data/ext/isomorfeus_ferret_ext/frt_search.c +105 -146
  63. data/ext/isomorfeus_ferret_ext/frt_search.h +331 -320
  64. data/ext/isomorfeus_ferret_ext/frt_similarity.c +5 -13
  65. data/ext/isomorfeus_ferret_ext/frt_similarity.h +7 -12
  66. data/ext/isomorfeus_ferret_ext/frt_sort.c +105 -149
  67. data/ext/isomorfeus_ferret_ext/frt_store.c +13 -7
  68. data/ext/isomorfeus_ferret_ext/frt_store.h +10 -2
  69. data/ext/isomorfeus_ferret_ext/frt_threading.h +0 -1
  70. data/ext/isomorfeus_ferret_ext/isomorfeus_ferret.c +21 -109
  71. data/ext/isomorfeus_ferret_ext/isomorfeus_ferret.h +2 -32
  72. data/ext/isomorfeus_ferret_ext/lz4.c +2495 -0
  73. data/ext/isomorfeus_ferret_ext/lz4.h +774 -0
  74. data/ext/isomorfeus_ferret_ext/lz4frame.c +1899 -0
  75. data/ext/isomorfeus_ferret_ext/lz4frame.h +623 -0
  76. data/ext/isomorfeus_ferret_ext/lz4hc.c +1615 -0
  77. data/ext/isomorfeus_ferret_ext/lz4hc.h +413 -0
  78. data/ext/isomorfeus_ferret_ext/lz4xxhash.c +1030 -0
  79. data/ext/isomorfeus_ferret_ext/lz4xxhash.h +328 -0
  80. data/ext/isomorfeus_ferret_ext/stem_modules.h +0 -86
  81. data/ext/isomorfeus_ferret_ext/test.c +1 -2
  82. data/ext/isomorfeus_ferret_ext/test_1710.c +11 -12
  83. data/ext/isomorfeus_ferret_ext/test_analysis.c +590 -583
  84. data/ext/isomorfeus_ferret_ext/test_compound_io.c +1 -1
  85. data/ext/isomorfeus_ferret_ext/test_document.c +19 -15
  86. data/ext/isomorfeus_ferret_ext/test_except.c +1 -2
  87. data/ext/isomorfeus_ferret_ext/test_fields.c +59 -60
  88. data/ext/isomorfeus_ferret_ext/test_file_deleter.c +10 -27
  89. data/ext/isomorfeus_ferret_ext/test_filter.c +11 -8
  90. data/ext/isomorfeus_ferret_ext/test_hash.c +2 -2
  91. data/ext/isomorfeus_ferret_ext/test_hashset.c +1 -1
  92. data/ext/isomorfeus_ferret_ext/test_highlighter.c +15 -11
  93. data/ext/isomorfeus_ferret_ext/test_index.c +372 -365
  94. data/ext/isomorfeus_ferret_ext/test_q_const_score.c +5 -3
  95. data/ext/isomorfeus_ferret_ext/test_q_filtered.c +5 -3
  96. data/ext/isomorfeus_ferret_ext/test_q_fuzzy.c +13 -10
  97. data/ext/isomorfeus_ferret_ext/test_q_parser.c +45 -7
  98. data/ext/isomorfeus_ferret_ext/test_q_span.c +15 -12
  99. data/ext/isomorfeus_ferret_ext/test_ram_store.c +3 -3
  100. data/ext/isomorfeus_ferret_ext/test_search.c +60 -62
  101. data/ext/isomorfeus_ferret_ext/test_segments.c +5 -4
  102. data/ext/isomorfeus_ferret_ext/test_sort.c +17 -14
  103. data/ext/isomorfeus_ferret_ext/test_store.c +2 -0
  104. data/ext/isomorfeus_ferret_ext/test_term.c +3 -1
  105. data/ext/isomorfeus_ferret_ext/test_term_vectors.c +9 -10
  106. data/ext/isomorfeus_ferret_ext/test_test.c +1 -2
  107. data/ext/isomorfeus_ferret_ext/test_threading.c +9 -10
  108. data/ext/isomorfeus_ferret_ext/testhelper.c +1 -2
  109. data/lib/isomorfeus/ferret/version.rb +1 -1
  110. metadata +27 -57
  111. data/ext/isomorfeus_ferret_ext/email.rl +0 -21
  112. data/ext/isomorfeus_ferret_ext/frt_scanner.c +0 -900
  113. data/ext/isomorfeus_ferret_ext/frt_scanner.h +0 -28
  114. data/ext/isomorfeus_ferret_ext/frt_scanner_mb.c +0 -6706
  115. data/ext/isomorfeus_ferret_ext/frt_scanner_utf8.c +0 -4420
  116. data/ext/isomorfeus_ferret_ext/scanner.h +0 -28
  117. data/ext/isomorfeus_ferret_ext/scanner.in +0 -43
  118. data/ext/isomorfeus_ferret_ext/scanner.rl +0 -84
  119. data/ext/isomorfeus_ferret_ext/scanner_mb.rl +0 -200
  120. data/ext/isomorfeus_ferret_ext/scanner_utf8.rl +0 -85
  121. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_basque.c +0 -1167
  122. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_basque.h +0 -6
  123. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_catalan.c +0 -1433
  124. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_catalan.h +0 -6
  125. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_danish.c +0 -301
  126. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_danish.h +0 -6
  127. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_dutch.c +0 -590
  128. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_dutch.h +0 -6
  129. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_english.c +0 -1049
  130. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_english.h +0 -6
  131. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_finnish.c +0 -705
  132. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_finnish.h +0 -6
  133. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_french.c +0 -1239
  134. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_french.h +0 -6
  135. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_german.c +0 -477
  136. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_german.h +0 -6
  137. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_hungarian.c +0 -1217
  138. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_hungarian.h +0 -7
  139. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_indonesian.c +0 -394
  140. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_indonesian.h +0 -6
  141. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_irish.c +0 -457
  142. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_irish.h +0 -6
  143. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_italian.c +0 -1009
  144. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_italian.h +0 -6
  145. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_norwegian.c +0 -259
  146. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_norwegian.h +0 -6
  147. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_porter.c +0 -704
  148. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_porter.h +0 -6
  149. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_portuguese.c +0 -948
  150. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_portuguese.h +0 -6
  151. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_spanish.c +0 -1028
  152. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_spanish.h +0 -6
  153. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_swedish.c +0 -275
  154. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_swedish.h +0 -6
  155. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_2_hungarian.c +0 -849
  156. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_2_hungarian.h +0 -6
  157. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_2_romanian.c +0 -952
  158. data/ext/isomorfeus_ferret_ext/stem_ISO_8859_2_romanian.h +0 -6
  159. data/ext/isomorfeus_ferret_ext/stem_KOI8_R_russian.c +0 -669
  160. data/ext/isomorfeus_ferret_ext/stem_KOI8_R_russian.h +0 -6
  161. data/ext/isomorfeus_ferret_ext/stem_modules.txt +0 -63
  162. data/ext/isomorfeus_ferret_ext/uchar-ucs4.rl +0 -1854
  163. data/ext/isomorfeus_ferret_ext/uchar-utf8.rl +0 -1999
  164. data/ext/isomorfeus_ferret_ext/url.rl +0 -27
@@ -13,8 +13,7 @@
13
13
  *
14
14
  ****************************************************************************/
15
15
 
16
- FrtTerm *frt_term_new(FrtSymbol field, const char *text)
17
- {
16
+ FrtTerm *frt_term_new(ID field, const char *text) {
18
17
  FrtTerm *t = FRT_ALLOC(FrtTerm);
19
18
  t->field = field;
20
19
  t->text = frt_estrdup(text);
@@ -44,8 +43,7 @@ unsigned long long frt_term_hash(const void *t)
44
43
  *
45
44
  ****************************************************************************/
46
45
 
47
- static float simdef_length_norm(FrtSimilarity *s, FrtSymbol field, int num_terms)
48
- {
46
+ static float simdef_length_norm(FrtSimilarity *s, ID field, int num_terms) {
49
47
  (void)s;
50
48
  (void)field;
51
49
  return (float)(1.0 / sqrt(num_terms));
@@ -69,17 +67,12 @@ static float simdef_sloppy_freq(struct FrtSimilarity *s, int distance)
69
67
  return (float)(1.0 / (double)(distance + 1));
70
68
  }
71
69
 
72
- static float simdef_idf_term(struct FrtSimilarity *s, FrtSymbol field, char *term,
73
- FrtSearcher *searcher)
74
- {
70
+ static float simdef_idf_term(struct FrtSimilarity *s, ID field, char *term, FrtSearcher *searcher) {
75
71
  return s->idf(s, searcher->doc_freq(searcher, field, term),
76
72
  searcher->max_doc(searcher));
77
73
  }
78
74
 
79
- static float simdef_idf_phrase(struct FrtSimilarity *s, FrtSymbol field,
80
- FrtPhrasePosition *positions,
81
- int pp_cnt, FrtSearcher *searcher)
82
- {
75
+ static float simdef_idf_phrase(struct FrtSimilarity *s, ID field, FrtPhrasePosition *positions, int pp_cnt, FrtSearcher *searcher) {
83
76
  float idf = 0.0f;
84
77
  int i, j;
85
78
  for (i = 0; i < pp_cnt; i++) {
@@ -136,8 +129,7 @@ static FrtSimilarity default_similarity = {
136
129
  &simdef_destroy
137
130
  };
138
131
 
139
- FrtSimilarity *frt_sim_create_default()
140
- {
132
+ FrtSimilarity *frt_sim_create_default(void) {
141
133
  int i;
142
134
  if (!default_similarity.data) {
143
135
  for (i = 0; i < 256; i++) {
@@ -9,13 +9,12 @@ typedef struct FrtSearcher FrtSearcher;
9
9
  *
10
10
  ****************************************************************************/
11
11
 
12
- typedef struct FrtTerm
13
- {
14
- FrtSymbol field;
12
+ typedef struct FrtTerm {
13
+ ID field;
15
14
  char *text;
16
15
  } FrtTerm;
17
16
 
18
- extern FrtTerm *frt_term_new(FrtSymbol field, const char *text);
17
+ extern FrtTerm *frt_term_new(ID field, const char *text);
19
18
  extern void frt_term_destroy(FrtTerm *self);
20
19
  extern int frt_term_eq(const void *t1, const void *t2);
21
20
  extern unsigned long long frt_term_hash(const void *t);
@@ -40,19 +39,15 @@ typedef struct FrtPhrasePosition
40
39
 
41
40
  typedef struct FrtSimilarity FrtSimilarity;
42
41
 
43
- struct FrtSimilarity
44
- {
42
+ struct FrtSimilarity {
45
43
  void *data;
46
44
  float norm_table[256];
47
- float (*length_norm)(FrtSimilarity *self, FrtSymbol field, int num_terms);
45
+ float (*length_norm)(FrtSimilarity *self, ID field, int num_terms);
48
46
  float (*query_norm)(FrtSimilarity *self, float sum_of_squared_weights);
49
47
  float (*tf)(FrtSimilarity *self, float freq);
50
48
  float (*sloppy_freq)(FrtSimilarity *self, int distance);
51
- float (*idf_term)(FrtSimilarity *self, FrtSymbol field, char *term,
52
- FrtSearcher *searcher);
53
- float (*idf_phrase)(FrtSimilarity *self, FrtSymbol field,
54
- FrtPhrasePosition *positions,
55
- int pp_cnt, FrtSearcher *searcher);
49
+ float (*idf_term)(FrtSimilarity *self, ID field, char *term, FrtSearcher *searcher);
50
+ float (*idf_phrase)(FrtSimilarity *self, ID field, FrtPhrasePosition *positions, int pp_cnt, FrtSearcher *searcher);
56
51
  float (*idf)(FrtSimilarity *self, int doc_freq, int num_docs);
57
52
  float (*coord)(FrtSimilarity *self, int overlap, int max_overlap);
58
53
  float (*decode_norm)(FrtSimilarity *self, unsigned char b);
@@ -3,68 +3,75 @@
3
3
  #include "frt_index.h"
4
4
  #include "frt_field_index.h"
5
5
 
6
+ #undef close
7
+
6
8
  /***************************************************************************
7
9
  *
8
10
  * FrtSortField
9
11
  *
10
12
  ***************************************************************************/
11
13
 
12
- static FrtSortField *sort_field_alloc(FrtSymbol field,
13
- SortType type,
14
- bool reverse,
14
+ FrtSortField *frt_sort_field_alloc(void) {
15
+ return FRT_ALLOC(FrtSortField);
16
+ }
17
+
18
+ static FrtSortField *sort_field_init(FrtSortField *self, ID field, SortType type, bool reverse,
15
19
  int (*compare)(void *index_ptr, FrtHit *hit1, FrtHit *hit2),
16
20
  void (*get_val)(void *index_ptr, FrtHit *hit1, FrtComparable *comparable),
17
- const FrtFieldIndexClass *field_index_class)
18
- {
19
- FrtSortField *self = FRT_ALLOC(FrtSortField);
21
+ const FrtFieldIndexClass *field_index_class) {
20
22
  self->field = field;
21
23
  self->type = type;
22
24
  self->reverse = reverse;
23
25
  self->field_index_class = field_index_class;
24
26
  self->compare = compare;
25
27
  self->get_val = get_val;
28
+ self->rfield = Qnil;
26
29
  return self;
27
30
  }
28
31
 
29
- FrtSortField *frt_sort_field_new(FrtSymbol field, SortType type, bool reverse)
30
- {
31
- FrtSortField *sf = NULL;
32
+ static FrtSortField *sort_field_new(ID field, SortType type, bool reverse,
33
+ int (*compare)(void *index_ptr, FrtHit *hit1, FrtHit *hit2),
34
+ void (*get_val)(void *index_ptr, FrtHit *hit1, FrtComparable *comparable),
35
+ const FrtFieldIndexClass *field_index_class) {
36
+ FrtSortField *self = frt_sort_field_alloc();
37
+ return sort_field_init(self, field, type, reverse, compare, get_val, field_index_class);
38
+ }
39
+
40
+ FrtSortField *frt_sort_field_init(FrtSortField *sf, ID field, SortType type, bool reverse) {
32
41
  switch (type) {
33
42
  case FRT_SORT_TYPE_SCORE:
34
- sf = frt_sort_field_score_new(reverse);
43
+ sf = frt_sort_field_score_init(sf, reverse);
35
44
  break;
36
45
  case FRT_SORT_TYPE_DOC:
37
- sf = frt_sort_field_doc_new(reverse);
46
+ sf = frt_sort_field_doc_init(sf, reverse);
38
47
  break;
39
48
  case FRT_SORT_TYPE_BYTE:
40
- sf = frt_sort_field_byte_new(field, reverse);
49
+ sf = frt_sort_field_byte_init(sf, field, reverse);
41
50
  break;
42
51
  case FRT_SORT_TYPE_INTEGER:
43
- sf = frt_sort_field_int_new(field, reverse);
52
+ sf = frt_sort_field_int_init(sf, field, reverse);
44
53
  break;
45
54
  case FRT_SORT_TYPE_FLOAT:
46
- sf = frt_sort_field_float_new(field, reverse);
55
+ sf = frt_sort_field_float_init(sf, field, reverse);
47
56
  break;
48
57
  case FRT_SORT_TYPE_STRING:
49
- sf = frt_sort_field_string_new(field, reverse);
58
+ sf = frt_sort_field_string_init(sf, field, reverse);
50
59
  break;
51
60
  case FRT_SORT_TYPE_AUTO:
52
- sf = frt_sort_field_auto_new(field, reverse);
61
+ sf = frt_sort_field_auto_init(sf, field, reverse);
53
62
  break;
54
63
  }
55
64
  return sf;
56
65
  }
57
66
 
58
- void frt_sort_field_destroy(void *p)
59
- {
67
+ void frt_sort_field_destroy(void *p) {
60
68
  free(p);
61
69
  }
62
70
 
63
71
  /*
64
72
  * field:<type>!
65
73
  */
66
- char *frt_sort_field_to_s(FrtSortField *self)
67
- {
74
+ char *frt_sort_field_to_s(FrtSortField *self) {
68
75
  char *str;
69
76
  const char *type = NULL;
70
77
  switch (self->type) {
@@ -106,14 +113,12 @@ char *frt_sort_field_to_s(FrtSortField *self)
106
113
  * ScoreSortField
107
114
  ***************************************************************************/
108
115
 
109
- static void sf_score_get_val(void *index, FrtHit *hit, FrtComparable *comparable)
110
- {
116
+ void frt_sort_field_score_get_val(void *index, FrtHit *hit, FrtComparable *comparable) {
111
117
  (void)index;
112
118
  comparable->val.f = hit->score;
113
119
  }
114
120
 
115
- static int sf_score_compare(void *index_ptr, FrtHit *hit2, FrtHit *hit1)
116
- {
121
+ int frt_sort_field_score_compare(void *index_ptr, FrtHit *hit2, FrtHit *hit1) {
117
122
  float val1 = hit1->score;
118
123
  float val2 = hit2->score;
119
124
  (void)index_ptr;
@@ -123,41 +128,27 @@ static int sf_score_compare(void *index_ptr, FrtHit *hit2, FrtHit *hit1)
123
128
  else return 0;
124
129
  }
125
130
 
126
- FrtSortField *frt_sort_field_score_new(bool reverse)
127
- {
128
- return sort_field_alloc((ID)NULL, FRT_SORT_TYPE_SCORE, reverse, &sf_score_compare, &sf_score_get_val, NULL);
131
+ FrtSortField *frt_sort_field_score_init(FrtSortField *self, bool reverse) {
132
+ return sort_field_init(self, (ID)NULL, FRT_SORT_TYPE_SCORE, reverse, &frt_sort_field_score_compare, &frt_sort_field_score_get_val, NULL);
129
133
  }
130
134
 
131
- const FrtSortField FRT_SORT_FIELD_SCORE = {
132
- NULL, /* field_index_class */
133
- (ID)NULL, /* field */
134
- FRT_SORT_TYPE_SCORE, /* type */
135
- false, /* reverse */
136
- &sf_score_compare, /* compare */
137
- &sf_score_get_val, /* get_val */
138
- };
135
+ FrtSortField *frt_sort_field_score_new(bool reverse) {
136
+ return sort_field_new((ID)NULL, FRT_SORT_TYPE_SCORE, reverse, &frt_sort_field_score_compare, &frt_sort_field_score_get_val, NULL);
137
+ }
139
138
 
140
- const FrtSortField FRT_SORT_FIELD_SCORE_REV = {
141
- NULL, /* field_index_class */
142
- (ID)NULL, /* field */
143
- FRT_SORT_TYPE_SCORE, /* type */
144
- true, /* reverse */
145
- &sf_score_compare, /* compare */
146
- &sf_score_get_val, /* get_val */
147
- };
139
+ FrtSortField *FRT_SORT_FIELD_SCORE;
140
+ FrtSortField *FRT_SORT_FIELD_SCORE_REV;
148
141
 
149
142
  /**************************************************************************
150
143
  * DocSortField
151
144
  ***************************************************************************/
152
145
 
153
- static void sf_doc_get_val(void *index, FrtHit *hit, FrtComparable *comparable)
154
- {
146
+ void frt_sort_field_doc_get_val(void *index, FrtHit *hit, FrtComparable *comparable) {
155
147
  (void)index;
156
148
  comparable->val.l = hit->doc;
157
149
  }
158
150
 
159
- static int sf_doc_compare(void *index_ptr, FrtHit *hit1, FrtHit *hit2)
160
- {
151
+ int frt_sort_field_doc_compare(void *index_ptr, FrtHit *hit1, FrtHit *hit2) {
161
152
  int val1 = hit1->doc;
162
153
  int val2 = hit2->doc;
163
154
  (void)index_ptr;
@@ -167,41 +158,26 @@ static int sf_doc_compare(void *index_ptr, FrtHit *hit1, FrtHit *hit2)
167
158
  else return 0;
168
159
  }
169
160
 
170
- FrtSortField *frt_sort_field_doc_new(bool reverse)
171
- {
172
- return sort_field_alloc((ID)NULL, FRT_SORT_TYPE_DOC, reverse,
173
- &sf_doc_compare, &sf_doc_get_val, NULL);
161
+ FrtSortField *frt_sort_field_doc_init(FrtSortField *self, bool reverse) {
162
+ return sort_field_init(self, (ID)NULL, FRT_SORT_TYPE_DOC, reverse, &frt_sort_field_doc_compare, &frt_sort_field_doc_get_val, NULL);
174
163
  }
175
164
 
176
- const FrtSortField FRT_SORT_FIELD_DOC = {
177
- NULL, /* field_index_class */
178
- (ID)NULL, /* field */
179
- FRT_SORT_TYPE_DOC, /* type */
180
- false, /* reverse */
181
- &sf_doc_compare, /* compare */
182
- &sf_doc_get_val, /* get_val */
183
- };
165
+ FrtSortField *frt_sort_field_doc_new(bool reverse) {
166
+ return sort_field_new((ID)NULL, FRT_SORT_TYPE_DOC, reverse, &frt_sort_field_doc_compare, &frt_sort_field_doc_get_val, NULL);
167
+ }
184
168
 
185
- const FrtSortField FRT_SORT_FIELD_DOC_REV = {
186
- NULL, /* field_index_class */
187
- (ID)NULL, /* field */
188
- FRT_SORT_TYPE_DOC, /* type */
189
- true, /* reverse */
190
- &sf_doc_compare, /* compare */
191
- &sf_doc_get_val, /* get_val */
192
- };
169
+ FrtSortField *FRT_SORT_FIELD_DOC;
170
+ FrtSortField *FRT_SORT_FIELD_DOC_REV;
193
171
 
194
172
  /***************************************************************************
195
173
  * ByteSortField
196
174
  ***************************************************************************/
197
175
 
198
- static void sf_byte_get_val(void *index, FrtHit *hit, FrtComparable *comparable)
199
- {
176
+ static void sf_byte_get_val(void *index, FrtHit *hit, FrtComparable *comparable) {
200
177
  comparable->val.l = ((long *)index)[hit->doc];
201
178
  }
202
179
 
203
- static int sf_byte_compare(void *index, FrtHit *hit1, FrtHit *hit2)
204
- {
180
+ static int sf_byte_compare(void *index, FrtHit *hit1, FrtHit *hit2) {
205
181
  long val1 = ((long *)index)[hit1->doc];
206
182
  long val2 = ((long *)index)[hit2->doc];
207
183
  if (val1 > val2) return 1;
@@ -209,24 +185,23 @@ static int sf_byte_compare(void *index, FrtHit *hit1, FrtHit *hit2)
209
185
  else return 0;
210
186
  }
211
187
 
212
- FrtSortField *frt_sort_field_byte_new(FrtSymbol field, bool reverse)
213
- {
214
- return sort_field_alloc(field, FRT_SORT_TYPE_BYTE, reverse,
215
- &sf_byte_compare, &sf_byte_get_val,
216
- &FRT_BYTE_FIELD_INDEX_CLASS);
188
+ FrtSortField *frt_sort_field_byte_init(FrtSortField *self, ID field, bool reverse) {
189
+ return sort_field_init(self, field, FRT_SORT_TYPE_BYTE, reverse, &sf_byte_compare, &sf_byte_get_val, &FRT_BYTE_FIELD_INDEX_CLASS);
190
+ }
191
+
192
+ FrtSortField *frt_sort_field_byte_new(ID field, bool reverse) {
193
+ return sort_field_new(field, FRT_SORT_TYPE_BYTE, reverse, &sf_byte_compare, &sf_byte_get_val, &FRT_BYTE_FIELD_INDEX_CLASS);
217
194
  }
218
195
 
219
196
  /***************************************************************************
220
197
  * IntegerSortField
221
198
  ***************************************************************************/
222
199
 
223
- static void sf_int_get_val(void *index, FrtHit *hit, FrtComparable *comparable)
224
- {
200
+ static void sf_int_get_val(void *index, FrtHit *hit, FrtComparable *comparable) {
225
201
  comparable->val.l = ((long *)index)[hit->doc];
226
202
  }
227
203
 
228
- static int sf_int_compare(void *index, FrtHit *hit1, FrtHit *hit2)
229
- {
204
+ static int sf_int_compare(void *index, FrtHit *hit1, FrtHit *hit2) {
230
205
  long val1 = ((long *)index)[hit1->doc];
231
206
  long val2 = ((long *)index)[hit2->doc];
232
207
  if (val1 > val2) return 1;
@@ -234,24 +209,23 @@ static int sf_int_compare(void *index, FrtHit *hit1, FrtHit *hit2)
234
209
  else return 0;
235
210
  }
236
211
 
237
- FrtSortField *frt_sort_field_int_new(FrtSymbol field, bool reverse)
238
- {
239
- return sort_field_alloc(field, FRT_SORT_TYPE_INTEGER, reverse,
240
- &sf_int_compare, &sf_int_get_val,
241
- &FRT_INTEGER_FIELD_INDEX_CLASS);
212
+ FrtSortField *frt_sort_field_int_init(FrtSortField *self, ID field, bool reverse) {
213
+ return sort_field_init(self, field, FRT_SORT_TYPE_INTEGER, reverse, &sf_int_compare, &sf_int_get_val, &FRT_INTEGER_FIELD_INDEX_CLASS);
214
+ }
215
+
216
+ FrtSortField *frt_sort_field_int_new(ID field, bool reverse) {
217
+ return sort_field_new(field, FRT_SORT_TYPE_INTEGER, reverse, &sf_int_compare, &sf_int_get_val, &FRT_INTEGER_FIELD_INDEX_CLASS);
242
218
  }
243
219
 
244
220
  /***************************************************************************
245
221
  * FloatSortField
246
222
  ***************************************************************************/
247
223
 
248
- static void sf_float_get_val(void *index, FrtHit *hit, FrtComparable *comparable)
249
- {
224
+ static void sf_float_get_val(void *index, FrtHit *hit, FrtComparable *comparable) {
250
225
  comparable->val.f = ((float *)index)[hit->doc];
251
226
  }
252
227
 
253
- static int sf_float_compare(void *index, FrtHit *hit1, FrtHit *hit2)
254
- {
228
+ static int sf_float_compare(void *index, FrtHit *hit1, FrtHit *hit2) {
255
229
  float val1 = ((float *)index)[hit1->doc];
256
230
  float val2 = ((float *)index)[hit2->doc];
257
231
  if (val1 > val2) return 1;
@@ -259,26 +233,25 @@ static int sf_float_compare(void *index, FrtHit *hit1, FrtHit *hit2)
259
233
  else return 0;
260
234
  }
261
235
 
262
- FrtSortField *frt_sort_field_float_new(FrtSymbol field, bool reverse)
263
- {
264
- return sort_field_alloc(field, FRT_SORT_TYPE_FLOAT, reverse,
265
- &sf_float_compare, &sf_float_get_val,
266
- &FRT_FLOAT_FIELD_INDEX_CLASS);
236
+ FrtSortField *frt_sort_field_float_init(FrtSortField *self, ID field, bool reverse) {
237
+ return sort_field_init(self, field, FRT_SORT_TYPE_FLOAT, reverse, &sf_float_compare, &sf_float_get_val, &FRT_FLOAT_FIELD_INDEX_CLASS);
238
+ }
239
+
240
+ FrtSortField *frt_sort_field_float_new(ID field, bool reverse) {
241
+ return sort_field_new(field, FRT_SORT_TYPE_FLOAT, reverse, &sf_float_compare, &sf_float_get_val, &FRT_FLOAT_FIELD_INDEX_CLASS);
267
242
  }
268
243
 
269
244
  /***************************************************************************
270
245
  * StringSortField
271
246
  ***************************************************************************/
272
247
 
273
- static void sf_string_get_val(void *index, FrtHit *hit, FrtComparable *comparable)
274
- {
248
+ static void sf_string_get_val(void *index, FrtHit *hit, FrtComparable *comparable) {
275
249
  comparable->val.s
276
250
  = ((FrtStringIndex *)index)->values[
277
251
  ((FrtStringIndex *)index)->index[hit->doc]];
278
252
  }
279
253
 
280
- static int sf_string_compare(void *index, FrtHit *hit1, FrtHit *hit2)
281
- {
254
+ static int sf_string_compare(void *index, FrtHit *hit1, FrtHit *hit2) {
282
255
  char *s1 = ((FrtStringIndex *)index)->values[
283
256
  ((FrtStringIndex *)index)->index[hit1->doc]];
284
257
  char *s2 = ((FrtStringIndex *)index)->values[
@@ -304,20 +277,24 @@ static int sf_string_compare(void *index, FrtHit *hit1, FrtHit *hit2)
304
277
  */
305
278
  }
306
279
 
307
- FrtSortField *frt_sort_field_string_new(FrtSymbol field, bool reverse)
308
- {
309
- return sort_field_alloc(field, FRT_SORT_TYPE_STRING, reverse,
310
- &sf_string_compare, &sf_string_get_val,
311
- &FRT_STRING_FIELD_INDEX_CLASS);
280
+ FrtSortField *frt_sort_field_string_init(FrtSortField *self, ID field, bool reverse) {
281
+ return sort_field_init(self, field, FRT_SORT_TYPE_STRING, reverse, &sf_string_compare, &sf_string_get_val, &FRT_STRING_FIELD_INDEX_CLASS);
282
+ }
283
+
284
+ FrtSortField *frt_sort_field_string_new(ID field, bool reverse) {
285
+ return sort_field_new(field, FRT_SORT_TYPE_STRING, reverse, &sf_string_compare, &sf_string_get_val, &FRT_STRING_FIELD_INDEX_CLASS);
312
286
  }
313
287
 
314
288
  /***************************************************************************
315
289
  * AutoSortField
316
290
  ***************************************************************************/
317
291
 
318
- FrtSortField *frt_sort_field_auto_new(FrtSymbol field, bool reverse)
319
- {
320
- return sort_field_alloc(field, FRT_SORT_TYPE_AUTO, reverse, NULL, NULL, NULL);
292
+ FrtSortField *frt_sort_field_auto_init(FrtSortField *self, ID field, bool reverse) {
293
+ return sort_field_init(self, field, FRT_SORT_TYPE_AUTO, reverse, NULL, NULL, NULL);
294
+ }
295
+
296
+ FrtSortField *frt_sort_field_auto_new(ID field, bool reverse) {
297
+ return sort_field_new(field, FRT_SORT_TYPE_AUTO, reverse, NULL, NULL, NULL);
321
298
  }
322
299
 
323
300
  /***************************************************************************
@@ -336,9 +313,7 @@ typedef struct Comparator {
336
313
  int (*compare)(void *index_ptr, FrtHit *hit1, FrtHit *hit2);
337
314
  } Comparator;
338
315
 
339
- static Comparator *comparator_new(void *index, bool reverse,
340
- int (*compare)(void *index_ptr, FrtHit *hit1, FrtHit *hit2))
341
- {
316
+ static Comparator *comparator_new(void *index, bool reverse, int (*compare)(void *index_ptr, FrtHit *hit1, FrtHit *hit2)) {
342
317
  Comparator *self = FRT_ALLOC(Comparator);
343
318
  self->index = index;
344
319
  self->reverse = reverse;
@@ -362,8 +337,7 @@ typedef struct Sorter {
362
337
  sf->compare = sf_ ## lower_type ## _compare;\
363
338
  sf->get_val = sf_ ## lower_type ## _get_val
364
339
 
365
- static void sort_field_auto_evaluate(FrtSortField *sf, char *text)
366
- {
340
+ static void sort_field_auto_evaluate(FrtSortField *sf, char *text) {
367
341
  int int_val;
368
342
  float float_val;
369
343
  int text_len = 0, scan_len = 0;
@@ -382,8 +356,7 @@ static void sort_field_auto_evaluate(FrtSortField *sf, char *text)
382
356
  }
383
357
  }
384
358
 
385
- static Comparator *sorter_get_comparator(FrtSortField *sf, FrtIndexReader *ir)
386
- {
359
+ static Comparator *sorter_get_comparator(FrtSortField *sf, FrtIndexReader *ir) {
387
360
  void *index = NULL;
388
361
  if (sf->type > FRT_SORT_TYPE_DOC) {
389
362
  FrtFieldIndex *field_index = NULL;
@@ -407,8 +380,7 @@ static Comparator *sorter_get_comparator(FrtSortField *sf, FrtIndexReader *ir)
407
380
  return comparator_new(index, sf->reverse, sf->compare);
408
381
  }
409
382
 
410
- static void sorter_destroy(Sorter *self)
411
- {
383
+ static void sorter_destroy(Sorter *self) {
412
384
  int i;
413
385
 
414
386
  for (i = 0; i < self->c_cnt; i++) {
@@ -418,8 +390,7 @@ static void sorter_destroy(Sorter *self)
418
390
  free(self);
419
391
  }
420
392
 
421
- static Sorter *sorter_new(FrtSort *sort)
422
- {
393
+ static Sorter *sorter_new(FrtSort *sort) {
423
394
  Sorter *self = FRT_ALLOC(Sorter);
424
395
  self->c_cnt = sort->size;
425
396
  self->comparators = FRT_ALLOC_AND_ZERO_N(Comparator *, self->c_cnt);
@@ -431,8 +402,7 @@ static Sorter *sorter_new(FrtSort *sort)
431
402
  * FieldSortedHitQueue
432
403
  ***************************************************************************/
433
404
 
434
- static bool fshq_less_than(const void *hit1, const void *hit2)
435
- {
405
+ static bool fshq_less_than(const void *hit1, const void *hit2) {
436
406
  int cmp = 0;
437
407
  printf("Whoops, shouldn't call this.\n");
438
408
  if (cmp != 0) {
@@ -442,8 +412,7 @@ static bool fshq_less_than(const void *hit1, const void *hit2)
442
412
  }
443
413
  }
444
414
 
445
- static bool fshq_lt(Sorter *sorter, FrtHit *hit1, FrtHit *hit2)
446
- {
415
+ static bool fshq_lt(Sorter *sorter, FrtHit *hit1, FrtHit *hit2) {
447
416
  Comparator *comp;
448
417
  int diff = 0, i;
449
418
  for (i = 0; i < sorter->c_cnt && diff == 0; i++) {
@@ -462,8 +431,7 @@ static bool fshq_lt(Sorter *sorter, FrtHit *hit1, FrtHit *hit2)
462
431
  }
463
432
  }
464
433
 
465
- void fshq_pq_down(FrtPriorityQueue *pq)
466
- {
434
+ void fshq_pq_down(FrtPriorityQueue *pq) {
467
435
  register int i = 1;
468
436
  register int j = 2; /* i << 1; */
469
437
  register int k = 3; /* j + 1; */
@@ -487,8 +455,7 @@ void fshq_pq_down(FrtPriorityQueue *pq)
487
455
  heap[i] = node;
488
456
  }
489
457
 
490
- FrtHit *frt_fshq_pq_pop(FrtPriorityQueue *pq)
491
- {
458
+ FrtHit *frt_fshq_pq_pop(FrtPriorityQueue *pq) {
492
459
  if (pq->size > 0) {
493
460
  FrtHit *hit = (FrtHit *)pq->heap[1]; /* save first value */
494
461
  pq->heap[1] = pq->heap[pq->size]; /* move last to first */
@@ -501,8 +468,7 @@ FrtHit *frt_fshq_pq_pop(FrtPriorityQueue *pq)
501
468
  }
502
469
  }
503
470
 
504
- static void fshq_pq_up(FrtPriorityQueue *pq)
505
- {
471
+ static void fshq_pq_up(FrtPriorityQueue *pq) {
506
472
  FrtHit **heap = (FrtHit **)pq->heap;
507
473
  FrtHit *node;
508
474
  int i = pq->size;
@@ -518,8 +484,7 @@ static void fshq_pq_up(FrtPriorityQueue *pq)
518
484
  heap[i] = node;
519
485
  }
520
486
 
521
- void frt_fshq_pq_insert(FrtPriorityQueue *pq, FrtHit *hit)
522
- {
487
+ void frt_fshq_pq_insert(FrtPriorityQueue *pq, FrtHit *hit) {
523
488
  if (pq->size < pq->capa) {
524
489
  FrtHit *new_hit = FRT_ALLOC(FrtHit);
525
490
  memcpy(new_hit, hit, sizeof(FrtHit));
@@ -537,14 +502,13 @@ void frt_fshq_pq_insert(FrtPriorityQueue *pq, FrtHit *hit)
537
502
  }
538
503
  }
539
504
 
540
- void frt_fshq_pq_destroy(FrtPriorityQueue *self)
541
- {
505
+ void frt_fshq_pq_destroy(FrtPriorityQueue *self) {
542
506
  sorter_destroy((Sorter *)self->heap[0]);
507
+ frt_pq_clear(self);
543
508
  frt_pq_destroy(self);
544
509
  }
545
510
 
546
- FrtPriorityQueue *frt_fshq_pq_new(int size, FrtSort *sort, FrtIndexReader *ir)
547
- {
511
+ FrtPriorityQueue *frt_fshq_pq_new(int size, FrtSort *sort, FrtIndexReader *ir) {
548
512
  FrtPriorityQueue *self = frt_pq_new(size, &fshq_less_than, &free);
549
513
  int i;
550
514
  Sorter *sorter = sorter_new(sort);
@@ -559,12 +523,10 @@ FrtPriorityQueue *frt_fshq_pq_new(int size, FrtSort *sort, FrtIndexReader *ir)
559
523
  return self;
560
524
  }
561
525
 
562
- FrtHit *frt_fshq_pq_pop_fd(FrtPriorityQueue *pq)
563
- {
526
+ FrtHit *frt_fshq_pq_pop_fd(FrtPriorityQueue *pq) {
564
527
  if (pq->size <= 0) {
565
528
  return NULL;
566
- }
567
- else {
529
+ } else {
568
530
  int j;
569
531
  Sorter *sorter = (Sorter *)pq->heap[0];
570
532
  const int cmp_cnt = sorter->c_cnt;
@@ -599,8 +561,7 @@ FrtHit *frt_fshq_pq_pop_fd(FrtPriorityQueue *pq)
599
561
  * FieldDocSortedHitQueue
600
562
  ***************************************************************************/
601
563
 
602
- bool frt_fdshq_lt(FrtFieldDoc *fd1, FrtFieldDoc *fd2)
603
- {
564
+ bool frt_fdshq_lt(FrtFieldDoc *fd1, FrtFieldDoc *fd2) {
604
565
  int i;
605
566
  bool c = false;
606
567
  bool all_equal = false;
@@ -725,8 +686,7 @@ bool frt_fdshq_lt(FrtFieldDoc *fd1, FrtFieldDoc *fd2)
725
686
 
726
687
  #define SORT_INIT_SIZE 4
727
688
 
728
- FrtSort *frt_sort_new()
729
- {
689
+ FrtSort *frt_sort_new(void) {
730
690
  FrtSort *self = FRT_ALLOC(FrtSort);
731
691
  self->size = 0;
732
692
  self->capa = SORT_INIT_SIZE;
@@ -737,8 +697,7 @@ FrtSort *frt_sort_new()
737
697
  return self;
738
698
  }
739
699
 
740
- void frt_sort_clear(FrtSort *self)
741
- {
700
+ void frt_sort_clear(FrtSort *self) {
742
701
  int i;
743
702
  if (self->destroy_all) {
744
703
  for (i = 0; i < self->size; i++) {
@@ -748,16 +707,14 @@ void frt_sort_clear(FrtSort *self)
748
707
  self->size = 0;
749
708
  }
750
709
 
751
- void frt_sort_destroy(void *p)
752
- {
710
+ void frt_sort_destroy(void *p) {
753
711
  FrtSort *self = (FrtSort *)p;
754
712
  frt_sort_clear(self);
755
713
  free(self->sort_fields);
756
714
  free(self);
757
715
  }
758
716
 
759
- void frt_sort_add_sort_field(FrtSort *self, FrtSortField *sf)
760
- {
717
+ void frt_sort_add_sort_field(FrtSort *self, FrtSortField *sf) {
761
718
  if (self->size == self->capa) {
762
719
  self->capa <<= 1;
763
720
  FRT_REALLOC_N(self->sort_fields, FrtSortField *, self->capa);
@@ -767,8 +724,7 @@ void frt_sort_add_sort_field(FrtSort *self, FrtSortField *sf)
767
724
  self->size++;
768
725
  }
769
726
 
770
- char *frt_sort_to_s(FrtSort *self)
771
- {
727
+ char *frt_sort_to_s(FrtSort *self) {
772
728
  int i, len = 20;
773
729
  char *s;
774
730
  char *str;
@@ -59,16 +59,24 @@ static void frt_close_lock_i(FrtLock *lock)
59
59
  /**
60
60
  * Create a store struct initializing the mutex.
61
61
  */
62
- FrtStore *frt_store_new()
63
- {
64
- FrtStore *store = FRT_ALLOC(FrtStore);
62
+ FrtStore *frt_store_alloc(void) {
63
+ return FRT_ALLOC(FrtStore);
64
+ }
65
+
66
+ FrtStore *frt_store_init(FrtStore *store) {
65
67
  store->ref_cnt = 1;
66
68
  frt_mutex_init(&store->mutex_i, NULL);
67
69
  frt_mutex_init(&store->mutex, NULL);
68
70
  store->locks = frt_hs_new_ptr((frt_free_ft)&frt_close_lock_i);
71
+ store->rstore = Qnil;
69
72
  return store;
70
73
  }
71
74
 
75
+ FrtStore *frt_store_new(void) {
76
+ FrtStore *store = frt_store_alloc();
77
+ return frt_store_init(store);
78
+ }
79
+
72
80
  /**
73
81
  * Destroy the store freeing allocated resources
74
82
  *
@@ -87,8 +95,7 @@ void frt_store_destroy(FrtStore *store)
87
95
  *
88
96
  * @return a newly allocated and initialized OutStream object
89
97
  */
90
- FrtOutStream *frt_os_new()
91
- {
98
+ FrtOutStream *frt_os_new(void) {
92
99
  FrtOutStream *os = FRT_ALLOC(FrtOutStream);
93
100
  os->buf.start = 0;
94
101
  os->buf.pos = 0;
@@ -180,8 +187,7 @@ void frt_os_write_bytes(FrtOutStream *os, const frt_uchar *buf, int len)
180
187
  *
181
188
  * @return a newly allocated and initialized InStream
182
189
  */
183
- FrtInStream *frt_is_new()
184
- {
190
+ FrtInStream *frt_is_new(void) {
185
191
  FrtInStream *is = FRT_ALLOC(FrtInStream);
186
192
  is->buf.start = 0;
187
193
  is->buf.pos = 0;