malloc 1.2.0 → 1.3.0

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.
Files changed (4) hide show
  1. data/Rakefile +1 -1
  2. data/lib/malloc_ext.rb +9 -0
  3. data/test/tc_malloc.rb +7 -0
  4. metadata +2 -2
data/Rakefile CHANGED
@@ -7,7 +7,7 @@ require 'rake/loaders/makefile'
7
7
  require 'rbconfig'
8
8
 
9
9
  PKG_NAME = 'malloc'
10
- PKG_VERSION = '1.2.0'
10
+ PKG_VERSION = '1.3.0'
11
11
  CXX = ENV[ 'CXX' ] || 'g++'
12
12
  STRIP = ENV[ 'STRIP' ] || 'strip'
13
13
  RB_FILES = FileList[ 'lib/**/*.rb' ]
@@ -90,6 +90,15 @@ module Hornetseye
90
90
  "Malloc(#{@size})"
91
91
  end
92
92
 
93
+ # Duplicate object
94
+ #
95
+ # @return [Malloc] A new malloc object with a copy of the data.
96
+ def dup
97
+ retval = Malloc.new @size
98
+ retval.write self
99
+ retval
100
+ end
101
+
93
102
  # Display information about this object
94
103
  #
95
104
  # @example Displaying information about a Malloc object
@@ -39,6 +39,13 @@ class TC_Malloc < Test::Unit::TestCase
39
39
  assert_equal 'Malloc(32)', Malloc.new( 32 ).to_s
40
40
  end
41
41
 
42
+ def test_dup
43
+ m = Malloc.new( 3 )
44
+ m.write 'abc'
45
+ m.dup.write 'def'
46
+ assert_equal 'abc', m.read( 3 )
47
+ end
48
+
42
49
  def test_read_write
43
50
  m = Malloc.new 6
44
51
  assert_equal 'abcdef', m.write( 'abcdef' )
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 1
7
- - 2
7
+ - 3
8
8
  - 0
9
- version: 1.2.0
9
+ version: 1.3.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Jan Wedekind