From: Daniel Berger Date: 2007-05-05T05:20:08+09:00 Subject: Problem with memcpy, marshal, zero Hi, Ruby 1.8.6 Windows XP Pro In the win32-mmap package I have the code setup such that you can create a dynamic accessor. Internally, I marshal the value (as a hash) and copy it to an address via memcpy (wrapped using Win32API). So, when you do something like this: mm = MMap.new(:size => 12, :name => 'test') mm.gvalue = 5 p mm.gvalue # 5 mm.close It's actually doing something like this when you set a value: h = {"gvalue"=>0} m = Marshal.dump(h) p m => "\004\b{\006\"\vgvaluei\000" memcpy(address, marshal, marshal.length) The problem is that trailing "\000" gets chopped off by the memcpy function because it treats it like a trailing null as far as I can tell. So, when I try to load it again the marshal data isn't identical, i.e. the trailing "\000" is gone, and I end up getting a "marshal data too short" error. What's the solution here? Thanks, Dan