diff options
author | ttate <ttate@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2002-04-11 08:07:01 +0000 |
---|---|---|
committer | ttate <ttate@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2002-04-11 08:07:01 +0000 |
commit | 3bd7404423c8a89297b52ff9496fa10b86d64046 (patch) | |
tree | b4b47e1aa195b4476878ee51d912cafc4905b9ec /ext/dl/lib | |
parent | 2990a0015324117f847bd2089ce945215cb23b4f (diff) | |
download | ruby-3bd7404423c8a89297b52ff9496fa10b86d64046.tar.gz |
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.rb | 13 |
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) |