c++ - How do I use FRESetContextNativeData() in AIR native extensions? -
i'm building ane. in 1 of calls native code, there's object gets created, , i'd able keep in memory reference in future call.
i thought could creating pointer object, , passing pointer fresetcontextnativedata() in example below:
freobject storedata(frecontext ctx, void* funcdata, uint32_t argc, freobject argv[]) { char* data = "testing..."; fresetcontextnativedata( ctx, &data ); return getfrestring(data); } freobject retrievedata(frecontext ctx, void* funcdata, uint32_t argc, freobject argv[]) { char* data; fregetcontextnativedata(ctx, (void**)&data); return getfrestring(data); }
this doesn't seem work however. @ end of retrievedata(), data
points bunch of randomness. gives?
so i'm bit of idiot. mistake made putting &
before data
in call fresetcontextnativedata(). 1 needs pointer, not pointer pointer fregetcontextnativedata().
the following code produces results expecting:
freobject storedata(frecontext ctx, void* funcdata, uint32_t argc, freobject argv[]) { char* data = "testing..." fresetcontextnativedata( ctx, (void*)data ); return getfrestring(data); } freobject retrievedata(frecontext ctx, void* funcdata, uint32_t argc, freobject argv[]) { char *data; fregetcontextnativedata(ctx, (void**)&data); return getfrestring(data); }
Comments
Post a Comment