[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: LuaJIT FFI: char[?] initialization from string
- From: Florian Weimer <fw@...>
- Date: Mon, 24 Jan 2011 14:36:45 +0100
* Leo Razoumov:
> On Mon, Jan 24, 2011 at 07:16, Florian Weimer <fw@deneb.enyo.de> wrote:
>> This:
>>
>> | local ffi = require "ffi"
>> | print(string.byte(ffi.string(ffi.new("char[3]", "ABC"), 3), 1, -1))
>>
>> prints:
>>
>> | 65 66 0
>>
>> I think this is rather surprising. I would have expected:
>>
>> | 65 66 67
>>
>> Is this a bug or a feature?
>>
>
> Could you try char[4] instead of char[3] ?
I'm using this as a workaround.