Re: luajit push_string out of memory

  • From: Sung Park <spark0820@xxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Tue, 26 Jun 2012 17:35:47 -0700

Since I'm using string library on the lua side, this won't work for me, but
I can see this will come in very handy later on.   Thanks for the
suggestion.

Regards,
Sung

On Mon, Jun 25, 2012 at 5:20 PM, demetri <demetri.spanos@xxxxxxxxx> wrote:

> Also I would appreciate it if anybody can share any good suggestions on
>> pushing large size string across C++/luajit boundary.  Thanks.
>>
>>
> If you're not planning on using string.* functions on it, I do this all
> the time using an ffi object:
>
> typedef struct {
>   int num_bytes;
>   char* payload;
> } CString;
>
> This avoids making a copy of the string (and interning it). Either
> instantiate such objects from ffi.new() on the lua side, or instantiate on
> the C side and pass a struct pointer as a lightuserdata (using ffi.cast()
> as appropriate).
>
> I have found this to solve all of my needs, but If others have better
> suggestions on best practices here I'd be curious to know as well :-)
>

Other related posts: