On 14.10.2008 15:37, Quentin Anciaux wrote: > virtual const uint8* GetAlpha () > > Who should delete the array ? is it a copy of internal structure or a > pointer to it (in which case it is deleted when csImageBase is deleted) ?
It's a pointer to internal data. Generally, unless otherwise noted in the docs, it's best to assume the returned pointer is owned by the class instance. > How can I know the length of the returned array ? is it ended by 0 ? How > can I know in general in the CS api ? Depends. In this particular case it is implicitly derived from the image dimensions (the array will have width x height elements). In other cases you get a GetSize() or similar method (e.g. iDataBuffer). String data is usually null terminated. > Also when for example a method return a csArray<something>, should I > send back a direct pointer to the elements contained in the array to the > java side or make a copy instead and return the pointer to the copy ? You might have to decide that case by case. Returning pointers to the array element directly is much more efficient (since you save the effort and memory for an additional copy etc), however, should the array be modified (can happen when a reference to an internal array is returned), the addresses of the elements can change. > If I delete a csArray<something> are all elements contained deleted ? > same questions for a something * ? Yes, no. (Well, technically the pointer value is destructed - however, this does not destruct the object pointed to.) -f.r.
signature.asc
Description: OpenPGP digital signature
------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________ Crystal-main mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/crystal-main Unsubscribe: mailto:[EMAIL PROTECTED]
