Hi,

Przemysław Czerpak wrote:
Yes it's really nice though it probably can be even simpler without
recursion.
This code allocates memory for index array using hb_xgrab() and needs
recursion only for allocating dynamically lFrom and lTo on C stack.
It means that it should be enough to allocate memory 3 times bigger
for lIndex[es], lFrom[s] and lTo[s] and convert array in two nested
loops.

I had this idea, but it's a kind of implementing carry flag for each number (dimension in this case) position manualy. Recursion was an easier for me :)


Hmm, it will be shorter and probably a little bit faster but I cannot
say if such version is more readable. It's necessary to compare final
code to answer. Maybe in some spare time ;-)

I guess it will be only faster, but not shorter :)


BTW in MS documentation dimensions are stored in 'unsigned int' instead
of 'int'. Maybe we should follow it?

MSDN writes:
   HRESULT SafeArrayGetDim( SAFEARRAY FAR* psa );

BCC wtypes.h has:
#ifndef _HRESULT_DEFINED
#define _HRESULT_DEFINED
typedef LONG HRESULT;
#endif // !_HRESULT_DEFINED


So, it's long, not unsigned int. But the most strange thing is that SafeArrayGetDim return HRESULT. Sounds like a handler, and this stopped me from beeper analysis. I just used int. Actually it was a bad idea, to not check real type.

Please, fix it.


Regards,
Mindaugas
_______________________________________________
Harbour mailing list (attachment size limit: 40KB)
Harbour@harbour-project.org
http://lists.harbour-project.org/mailman/listinfo/harbour

Reply via email to