free 0.2.0pre1-i386-mingw32 → 0.2.5-i386-mingw32

Sign up to get free protection for your applications and to get access to all the features.
data/HISTORY CHANGED
@@ -1,3 +1,6 @@
1
+ 4/1/2011 version 0.2.5
2
+ * added Free.free() (for freeing multiple values) (credit to coderrr)
3
+
1
4
  4/1/2011 version 0.2.0
2
5
  * added destructors
3
6
  * added greater error checking
data/README.md CHANGED
@@ -50,6 +50,7 @@ Features and limitations
50
50
  * Works in both Ruby 1.8 and 1.9.
51
51
  * Some protection from freeing critical objects and immediate values.
52
52
  * Supports object destructors
53
+ * Can free multiple objects at same time, e.g: `Free.free a, b, c`
53
54
 
54
55
  ### Limitations
55
56
 
data/Rakefile CHANGED
@@ -1,12 +1,6 @@
1
1
  dlext = Config::CONFIG['DLEXT']
2
2
  direc = File.dirname(__FILE__)
3
3
 
4
- begin
5
- require 'bones'
6
- rescue LoadError
7
- abort '### Please install the "bones" gem ###'
8
- end
9
-
10
4
  PROJECT_NAME = "free"
11
5
 
12
6
  require 'rake/clean'
@@ -18,14 +12,6 @@ CLEAN.include("ext/**/*.#{dlext}", "ext/**/*.log", "ext/**/*.o",
18
12
  "ext/**/*~", "ext/**/*#*", "ext/**/*.obj", "**/*#*", "**/*#*.*",
19
13
  "ext/**/*.def", "ext/**/*.pdb", "**/*_flymake*.*", "**/*_flymake")
20
14
 
21
- Bones do
22
- name 'free'
23
- authors 'John Mair (banisterfiend)'
24
- email 'jrmair@gmail.com'
25
- url 'http://banisterfiend.wordpress.com'
26
- ignore_file '.gitignore'
27
- end
28
-
29
15
  def apply_spec_defaults(s)
30
16
  s.name = PROJECT_NAME
31
17
  s.summary = "Force immediate garbage collection of an object."
data/ext/free/free.c CHANGED
@@ -91,7 +91,7 @@ make_deferred(RVALUE *p)
91
91
 
92
92
  #endif
93
93
 
94
- VALUE object_free(VALUE obj)
94
+ VALUE rb_object_free(VALUE obj)
95
95
  {
96
96
  ID id_destructor = rb_intern("__destruct__");
97
97
 
@@ -384,10 +384,20 @@ VALUE object_free(VALUE obj)
384
384
  return destruct_value;
385
385
  }
386
386
 
387
+ VALUE
388
+ rb_object_free_args(int argc, VALUE *argv, VALUE self)
389
+ {
390
+ for (int i = 0; i < argc; i++)
391
+ rb_object_free(argv[i]);
392
+
393
+ return Qnil;
394
+ }
395
+
387
396
  void
388
397
  Init_free()
389
398
  {
390
399
  VALUE cFree = rb_define_module("Free");
391
400
 
392
- rb_define_method(cFree, "free", object_free, 0);
401
+ rb_define_method(cFree, "free", rb_object_free, 0);
402
+ rb_define_singleton_method(cFree, "free", rb_object_free_args, -1);
393
403
  }
data/ext/free/free.h CHANGED
@@ -2,5 +2,6 @@
2
2
  #define GUARD_FREE_H
3
3
 
4
4
  VALUE rb_object_free(VALUE obj);
5
+ VALUE rb_object_free_args(int argc, VALUE *argv, VALUE self);
5
6
 
6
7
  #endif
data/lib/1.8/free.so CHANGED
Binary file
data/lib/1.9/free.so CHANGED
Binary file
data/lib/free.rb CHANGED
@@ -8,6 +8,17 @@ require "#{direc}/free/version"
8
8
  # @author John Mair (banisterfiend)
9
9
  module Free
10
10
 
11
+ # Free multiple objects at once.
12
+ # @param [Array] args The objects to free.
13
+ # @return [nil] Returns nil.
14
+ # @example
15
+ # h = "hello"
16
+ # g = "goodbye"
17
+ # m = "good morning"
18
+ #
19
+ # Free.free h, g, m
20
+ def self.free(*args) end
21
+
11
22
  # Force garbage collection on an object and free its internal structures.
12
23
  # @return [nil, Object] Return value of \_\_destruct\_\_ method (if
13
24
  # defined) or nil (if no \_\_destruct\_\_ method)
data/lib/free/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Free
2
- VERSION = "0.2.0pre1"
2
+ VERSION = "0.2.5"
3
3
  end
data/test/test.rb CHANGED
@@ -11,7 +11,7 @@ describe Free do
11
11
 
12
12
  ["hello", Object.new, Class.new, /hello/, [], {}, 10.5].each do |v|
13
13
  it "should free a #{v.class}" do
14
- v
14
+
15
15
  # make sure test doesn't pass as a result of normal garbage
16
16
  # collection, so keep a reference to v
17
17
  c = v
@@ -33,6 +33,17 @@ describe Free do
33
33
  end
34
34
  end
35
35
 
36
+ it 'should free multiple objects at once' do
37
+ a,b,c = 'a','b','c'
38
+ a_id, b_id, c_id = a.object_id, b.object_id, c.object_id
39
+
40
+ Free.free a, b, c
41
+
42
+ [a_id, b_id, c_id].each do |id|
43
+ (ObjectSpace._id2ref(id) != v || lambda { ObjectSpace._id2ref(id) } rescue true).should == true
44
+ end
45
+ end
46
+
36
47
  it 'should run destructor before freeing object' do
37
48
  o = Object.new
38
49
 
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: free
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: true
4
+ hash: 29
5
+ prerelease: false
5
6
  segments:
6
7
  - 0
7
8
  - 2
8
- - 0pre1
9
- version: 0.2.0pre1
9
+ - 5
10
+ version: 0.2.5
10
11
  platform: i386-mingw32
11
12
  authors:
12
13
  - John Mair (banisterfiend)
@@ -73,19 +74,19 @@ required_ruby_version: !ruby/object:Gem::Requirement
73
74
  requirements:
74
75
  - - ">="
75
76
  - !ruby/object:Gem::Version
77
+ hash: 3
76
78
  segments:
77
79
  - 0
78
80
  version: "0"
79
81
  required_rubygems_version: !ruby/object:Gem::Requirement
80
82
  none: false
81
83
  requirements:
82
- - - ">"
84
+ - - ">="
83
85
  - !ruby/object:Gem::Version
86
+ hash: 3
84
87
  segments:
85
- - 1
86
- - 3
87
- - 1
88
- version: 1.3.1
88
+ - 0
89
+ version: "0"
89
90
  requirements: []
90
91
 
91
92
  rubyforge_project: