[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: GC or Scope problem?!! (Passing pointer to Lua)
- From: David Given <dg@...>
- Date: Mon, 11 Apr 2005 11:24:27 +0100
On Mon, 2005-04-11 at 18:44 +0900, Nelson Wong wrote:
> I am having a problem with passing pointer to Lua script.
> I want to to be able to create a game stage from the scripts.
I do notice one thing:
> MyStage * myStage;
> Script.run("CreateStage", myStage);
You're passing an uninitialised pointer in here...
> CreateStage = function(stage)
> stage = MyStage:Create();
...which you're never modifying (assign a value to 'stage' will just
modify the value of the local variable. In fact, because you're never
returning 'stage' from your function, the value will be thrown away from
the garbage collector when the function exits.)
What are you expecting to happen? What is a MyStage, and who do you want
to own it (C++, or Lua)?
+- David Given --McQ-+ "There is nothing in the world so dangerous ---
| email@example.com | and I mean *nothing* --- as a children's story that
| (firstname.lastname@example.org) | happens to be true." --- Master Li Kao, _The Bridge
+- www.cowlark.com --+ of Birds_