Advertisement

Pointer access to a primiter memory area

Started by June 08, 2006 10:20 AM
1 comment, last by Lbas 18 years, 5 months ago
Hi, I would like to be able writing something like this in my scipts : uint8* p = GetDataPtr(); for( ...; ... ;... ) { uint n = *p; p++; } I know that pointer are (still :)) not allowed, but is there any other way (using references or such) to do that without registering complex object ? The reason here is for performance issue : accessing buffer using some GetData( nIdx ) registered method is very very slower than getting a pointer on it and walk through datas (while it's not safe:)), so parsing huge amount of datas (like image processing :)) is a big issue. Thanks in advance, Lbas
Lbas
Until AngelScript supports true pointers, the fastest you can get is probably something like this:

// AngelScriptint p = GetDataPtr();for( ...;...;... ){   uint n = GetRef(p);   p++;}


Where GetRef() is:

// C++char *GetRef(char *p) {    return p; }engine->RegisterGlobalFunction("uint8 &GetRef(int)", asFUNCTION(GetRef), asCALL_CDECL);

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

Advertisement
Thanks WitchLord,
It works fine and it's an alternative to write more optimized algorithms, we would just have to replace all 'GetRef(p)' with '*p' when it will be available.
Thanks a lot,
Lbas
Lbas

This topic is closed to new replies.

Advertisement