visualize_helper 0.0.10.28 → 0.0.10.29

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b4100947c618bdc4518f2f89923495306bfbecfb
4
- data.tar.gz: 04e6517f9f601470538a1f11fc706df5fa593752
3
+ metadata.gz: 2081c92edf54016d0da84ba7aa9ffff919a91047
4
+ data.tar.gz: 5658ac102b330baeeb445893283cf0342cd3416f
5
5
  SHA512:
6
- metadata.gz: a86285f6896472865180c8ce1e303eb2d4752698aad4a0e55744bd1ebcf5058409294c8852f576b82581903471dcbd8b74414a57cc44277951ac179c1831c9cc
7
- data.tar.gz: 7d534c2c3bf23c1d72b329a39ec105124a02feb129dee77adee43969f2e73a9011c8df3266070d0fd0c5d87350ca9781e1d3f92858abe2e7588b7d0b024312c1
6
+ metadata.gz: 8dd622af5cb8ee68bac527d43e3c064f6d50781756efdf195e42e8a3c83a847a061504d93ae2ad03c672f72d563898438451da59c48ef6cefa1610284220b152
7
+ data.tar.gz: 96493a67b86f2c5fae8dd8529a8001aade1c5e72c63d71e2ec911b31b9b41014fe2bd9b91cde9cad736eff2ccf310e96419ae6ac2cc80e91dd83a107fc46a2af
data/README.md CHANGED
@@ -24,7 +24,7 @@ TODO: Write usage instructions here
24
24
 
25
25
  ## Contributing
26
26
 
27
- 1. Fork it ( https://github.com/[my-github-username]/visualize_helper/fork )
27
+ 1. Fork it ( https://github.com/raphaottoni/visualize_helper/fork )
28
28
  2. Create your feature branch (`git checkout -b my-new-feature`)
29
29
  3. Commit your changes (`git commit -am 'Add some feature'`)
30
30
  4. Push to the branch (`git push origin my-new-feature`)
@@ -43,32 +43,41 @@ static VALUE uniq(VALUE sorted_array){
43
43
  }
44
44
 
45
45
  //static VALUE join(VALUE self, VALUE strings){
46
- static VALUE join(VALUE strings){
46
+ static char* join(VALUE strings){
47
47
 
48
48
  // initial variables
49
49
  char* joined;
50
50
  int strings_size = RARRAY_LEN(strings);
51
51
  int string_size;
52
+ int string_total_size = 0;
52
53
  VALUE string_temp;
53
54
  VALUE result;
55
+ //FILE *f = fopen("file.txt", "w");
54
56
 
55
- string_temp = rb_ary_entry(strings,0);
57
+
58
+
59
+ // calculate the exact size of malloc
60
+ for ( int i = 0; i < strings_size; i++) {
61
+ string_temp = rb_ary_entry(strings,i);
62
+ string_total_size += strlen(StringValuePtr(string_temp));
63
+ }
64
+
65
+ joined = (char*) malloc( string_total_size + strings_size + 1);
56
66
  string_size = strlen(StringValuePtr(string_temp));
57
- joined = (char*) malloc(strings_size + 1);
58
67
  sprintf(joined,"%s", StringValuePtr(string_temp));
59
68
 
69
+
60
70
  for (int i = 1 ; i < strings_size; i++) {
61
71
 
62
72
  string_temp = rb_ary_entry(strings,i);
63
- string_size = strlen(StringValuePtr(string_temp));
64
-
65
- joined = (char*) realloc(joined, string_size + strlen(joined) + 1);
66
73
  sprintf(joined,"%s,%s", joined, StringValuePtr(string_temp));
67
74
 
68
75
  }
69
- result = rb_str_new2(joined);
70
- free(joined);
71
- return result;
76
+ //result = rb_str_new2(joined);
77
+ //free(joined);
78
+ //fprintf(f,"%s\n",joined);
79
+ //fclose(f);
80
+ return joined;
72
81
  }
73
82
 
74
83
 
@@ -225,8 +234,8 @@ static VALUE remove_entry_from_array (VALUE strings, char* element){
225
234
  static VALUE generate_boxes_and_links(VALUE self, VALUE min, VALUE max, VALUE aggr, VALUE boxes, VALUE links, VALUE dict, VALUE type_agroupment, VALUE value)
226
235
  {
227
236
 
228
- VALUE seq_key_result;
229
- VALUE prox_key_result;
237
+ char* seq_key_result;
238
+ char* prox_key_result;
230
239
  // Initial Variables
231
240
  int length_seq_sorted;
232
241
  int length_prox_sorted;
@@ -283,11 +292,11 @@ static VALUE generate_boxes_and_links(VALUE self, VALUE min, VALUE max, VALUE ag
283
292
  seq_key_result = join(seq_key);
284
293
 
285
294
  //
286
- boxes_period_value = rb_hash_aref(rb_ary_entry(boxes,period),seq_key_result);
295
+ boxes_period_value = rb_hash_aref(rb_ary_entry(boxes,period),rb_str_new2(seq_key_result));
287
296
  if (boxes_period_value == Qnil) {
288
- rb_hash_aset(rb_ary_entry(boxes,period),seq_key_result, value);
297
+ rb_hash_aset(rb_ary_entry(boxes,period),rb_str_new2(seq_key_result), value);
289
298
  }else {
290
- rb_hash_aset(rb_ary_entry(boxes,period),seq_key_result,INT2FIX(FIX2INT(boxes_period_value) + FIX2INT(value)));
299
+ rb_hash_aset(rb_ary_entry(boxes,period),rb_str_new2(seq_key_result),INT2FIX(FIX2INT(boxes_period_value) + FIX2INT(value)));
291
300
  }
292
301
 
293
302
  prox = period +1;
@@ -327,8 +336,8 @@ static VALUE generate_boxes_and_links(VALUE self, VALUE min, VALUE max, VALUE ag
327
336
  prox_s = ( prox == 0 ) ? (char*) malloc(1) : (char*) malloc(floor(log10(abs(prox))) + 1);
328
337
  sprintf(period_s,"%d",period);
329
338
  sprintf(prox_s,"%d",prox);
330
- link_key = (char*) malloc( strlen(period_s) + strlen(StringValuePtr(seq_key_result)) + strlen(prox_s) + strlen(StringValuePtr(prox_key_result)) + 3);
331
- sprintf(link_key,"%s_%s;%s_%s", period_s,StringValuePtr(seq_key_result),prox_s,StringValuePtr(prox_key_result));
339
+ link_key = (char*) malloc( strlen(period_s) + strlen(seq_key_result) + strlen(prox_s) + strlen(prox_key_result) + 3);
340
+ sprintf(link_key,"%s_%s;%s_%s", period_s,seq_key_result,prox_s,prox_key_result);
332
341
 
333
342
  links_period_value = rb_hash_aref(rb_ary_entry(links,period),rb_str_new2(link_key));
334
343
  if (links_period_value == Qnil) {
@@ -337,15 +346,14 @@ static VALUE generate_boxes_and_links(VALUE self, VALUE min, VALUE max, VALUE ag
337
346
  rb_hash_aset(rb_ary_entry(links,period),rb_str_new2(link_key), INT2FIX(FIX2INT(links_period_value) + FIX2INT(value)));
338
347
  }
339
348
 
340
-
349
+ free(period_s);
350
+ free(prox_s);
351
+ free(link_key);
341
352
 
342
353
  }//end prox < aggr_size
343
354
 
344
355
  }// end for
345
356
 
346
- VALUE ab = rb_ary_new();
347
- rb_ary_push(ab,1);
348
- rb_ary_push(ab,2);
349
357
  //return result_final;
350
358
  return Qnil;
351
359
  }
@@ -368,5 +376,5 @@ void Init_visualize_helper(void) {
368
376
  rb_define_singleton_method(mVisualizeHelper, "sort_uniq", sort_uniq, 2 );
369
377
 
370
378
  // Register the method sort
371
- rb_define_singleton_method(mVisualizeHelper, "join", join, 1 );
379
+ //rb_define_singleton_method(mVisualizeHelper, "join", join, 1 );
372
380
  }
@@ -1,3 +1,3 @@
1
1
  module VisualizeHelper
2
- VERSION = "0.0.10.28"
2
+ VERSION = "0.0.10.29"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: visualize_helper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.10.28
4
+ version: 0.0.10.29
5
5
  platform: ruby
6
6
  authors:
7
7
  - Raphael Ottoni Santiago Machado de Faria