lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Thu, Sep 2, 2010 at 4:30 PM, Jonathan Castello <twisolar@gmail.com> wrote:
> On Thu, Sep 2, 2010 at 1:27 PM, Ted Unangst <ted.unangst@gmail.com> wrote:
>> What happens when you resize an image?  You need to allocate more
>> memory.  You can't modify all the Lua references to the old image, so
>> you need the Lua refs to be shallow pointers to the real data.  And
>> allocating the real data as userdata too, and then hanging a reference
>> to it, gets to be a pain.  You could make all operations return new
>> images, but that's quite inefficient.
>
> Hmm, see, since the OP said that they were using a "structure", I
> assumed the userdatum was not the image itself but rather a structure
> containing a pointer to an image.

That's exactly the interpretation I had.  The idea is that the current
shallow userdatum allows swapping out the heavy data.  Moving the
heavy data into the userdatum has a number of drawbacks.