summaryrefslogtreecommitdiff
path: root/ext/dl/lib
diff options
context:
space:
mode:
authorttate <ttate@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-04-11 08:07:01 +0000
committerttate <ttate@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-04-11 08:07:01 +0000
commit3bd7404423c8a89297b52ff9496fa10b86d64046 (patch)
treeb4b47e1aa195b4476878ee51d912cafc4905b9ec /ext/dl/lib
parent2990a0015324117f847bd2089ce945215cb23b4f (diff)
Add DL::Importable::Internal::Struct#alloc.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2360 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/dl/lib')
-rw-r--r--ext/dl/lib/dl/struct.rb13
1 files changed, 9 insertions, 4 deletions
diff --git a/ext/dl/lib/dl/struct.rb b/ext/dl/lib/dl/struct.rb
index 57703801a6..faa1377c51 100644
--- a/ext/dl/lib/dl/struct.rb
+++ b/ext/dl/lib/dl/struct.rb
@@ -74,14 +74,19 @@ module DL
return @names
end
- def new(size = nil)
+ # ptr must be a PtrData object.
+ def new(ptr)
+ ptr.struct!(@tys, *@names)
+ mem = Memory.new(ptr, @names, @ty, @len, @enc, @dec)
+ return mem
+ end
+
+ def alloc(size = nil)
if( !size )
size = @size
end
ptr = DL::malloc(size)
- ptr.struct!(@tys, *@names)
- mem = Memory.new(ptr, @names, @ty, @len, @enc, @dec)
- return mem
+ return new(ptr)
end
def parse(contents)