thorsson_cups 0.0.38 → 0.0.39

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/ext/cups.c +8 -44
  2. metadata +1 -1
data/ext/cups.c CHANGED
@@ -196,22 +196,6 @@ static VALUE cups_show_dests(VALUE self)
196
196
  return dest_list;
197
197
  }
198
198
 
199
- static VALUE cups_test(VALUE self)
200
- {
201
- int num_dests = cupsGetDests(&dests); // Size of dest_list array
202
- cupsFreeDests(num_dests, dests);
203
- return Qtrue;
204
- }
205
-
206
- static VALUE cups_test2(VALUE self)
207
- {
208
- int i, j;
209
- i = 1;
210
- j = 2;
211
- i = i + j;
212
- return Qtrue;
213
- }
214
-
215
199
  /*
216
200
  * call-seq:
217
201
  * Cups.default_printer -> String or nil
@@ -225,8 +209,9 @@ static VALUE cups_get_default(VALUE self)
225
209
 
226
210
  if (default_printer != NULL) {
227
211
  VALUE def_p = rb_str_new2(default_printer);
228
- if(default_printer != NULL)
229
- free(default_printer);
212
+
213
+ cupsFreeDests(default_printer);
214
+
230
215
  return def_p;
231
216
  }
232
217
  // should return nil if no default printer is found!
@@ -251,8 +236,8 @@ static VALUE cups_cancel(VALUE self)
251
236
  char *target = RSTRING_PTR(printer); // Target printer string
252
237
  int cancellation;
253
238
  cancellation = cupsCancelJob(target, job);
254
- if(target != NULL)
255
- free(target);
239
+
240
+ cupsFreeDests(cancellation);
256
241
  return Qtrue;
257
242
  }
258
243
  }
@@ -460,7 +445,7 @@ static VALUE cups_get_jobs(VALUE self, VALUE printer)
460
445
  if(printer_arg != NULL)
461
446
  free(printer_arg);
462
447
 
463
-
448
+ cupsFreeDests(num_jobs, jobs);
464
449
  return job_list;
465
450
  }
466
451
 
@@ -589,33 +574,14 @@ static VALUE cups_get_options(VALUE self, VALUE printer)
589
574
  cups_dest_t *dest = cupsGetDest(printer_arg, NULL, num_dests, dests);
590
575
 
591
576
  if (dest == NULL) {
592
- cupsFreeDests(num_dests, dests);
593
-
594
- if(printer_arg != NULL)
595
- free(printer_arg);
596
-
597
- if(dests != NULL)
598
- free(dests);
599
-
600
- if(dest != NULL)
601
- free(dest);
602
-
577
+ cupsFreeDests(num_dests, dests);
603
578
  return Qnil;
604
579
  } else {
605
580
  for(i =0; i< dest->num_options; i++) {
606
581
  rb_hash_aset(options_list, rb_str_new2(dest->options[i].name), rb_str_new2(dest->options[i].value));
607
582
  }
608
583
 
609
- cupsFreeDests(num_dests, dests);
610
-
611
- if(printer_arg != NULL)
612
- free(printer_arg);
613
-
614
- if(dests != NULL)
615
- free(dests);
616
-
617
- if(dest != NULL)
618
- free(dest);
584
+ cupsFreeDests(num_dests, dests, dest);
619
585
 
620
586
  return options_list;
621
587
  }
@@ -648,8 +614,6 @@ void Init_cups() {
648
614
 
649
615
  // Cups Module Methods
650
616
  rb_define_singleton_method(rubyCups, "show_destinations", cups_show_dests, 0);
651
- rb_define_singleton_method(rubyCups, "test", cups_test, 0);
652
- rb_define_singleton_method(rubyCups, "test2", cups_test2, 0);
653
617
  rb_define_singleton_method(rubyCups, "default_printer", cups_get_default, 0);
654
618
  rb_define_singleton_method(rubyCups, "all_jobs", cups_get_jobs, 1);
655
619
  rb_define_singleton_method(rubyCups, "cancel_print", cups_cancel_print, -1);
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: thorsson_cups
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.38
4
+ version: 0.0.39
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: