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 | d37d73bbd93af11ce27816f8bd1c314a642a9b46 (patch) | |
| tree | b4b47e1aa195b4476878ee51d912cafc4905b9ec /ext/dl/lib | |
| parent | f509b459871e0d767fd86fbbe0f849d4e282e8b5 (diff) | |
| download | ruby-d37d73bbd93af11ce27816f8bd1c314a642a9b46.tar.gz ruby-d37d73bbd93af11ce27816f8bd1c314a642a9b46.tar.xz ruby-d37d73bbd93af11ce27816f8bd1c314a642a9b46.zip | |
Add DL::Importable::Internal::Struct#alloc.
git-svn-id: http://svn.ruby-lang.org/repos/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 57703801a..faa1377c5 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) |
