[PATCH libxkbcommon] keymap: add xkb_keymap_new_from_memory()

Bill Spitzak spitzak at gmail.com
Mon Mar 11 11:06:32 PDT 2013


Okay looking more at your patch and the output of flex, I think you can 
just call yy_scan_bytes. It does a copy, true, but that is exactly what 
your code is doing. And it does it by reusing code that is already in 
the flex output.

And if flex is ever fixed so the two nulls are not needed, it seems 
likely yy_scan_bytes will be fixed to not do the copy (a fix might be to 
copy "blocks" into the parsing buffer, which is what it is doing for files).

I did fix our code which was adding +1 to strlen when calling 
yy_scan_bytes, due to a misunderstanding of the flex documentation. It 
obviously works without this.

Bill Spitzak wrote:
> Oops, never mind, it looks like you have already analyzed yy_scan_byte 
> and found it calls yy_scan_buffer internally (!!!). Oh well.
> 
> David Herrmann wrote:
> 
>> Internally, we depend on yy_scan_{string,byte}() helpers. According to
>> flex documentation these already copy the input string because they are
>> wrappers around yy_scan_buffer().
>> yy_scan_buffer() on the other hand has some insane requirements. The
>> buffer must be writeable and the last two bytes must be ASCII-NUL. But 
>> the
>> buffer may contain other 0 bytes just fine.


More information about the wayland-devel mailing list