Hi Teo, thanks for caring about my doubts, but I think I am not understood very well. See the following example (trivial). Sorry for my poor English. Thank in avance, Claudio Soto.
//******************************************** Function Main SET_ARRAY_DATOS (.F.,.T.,.T.) ? RET_CONT () // other lines of code RELEASE_ARRAY_DATOS () // <===== before the program ends I have necessarily to call RELEASE_ARRAY_DATOS ???? // or HARBOUR automatically released pArray at the end of the program. Return //********************************************* #pragma begindump #include "hbapi.h" #include "hbapiitm.h" BOOL flag = FALSE; PHB_ITEM pArray; int cont = 0; HB_FUNC (SET_ARRAY_DATOS) { if (flag == FALSE) { flag = TRUE; cont = 0; pArray = hb_itemNew (NULL); hb_arrayNew (pArray, 3); } hb_arraySetL (pArray, 1, hb_parl (1)); hb_arraySetL (pArray, 2, hb_parl (2)); hb_arraySetL (pArray, 3, hb_parl (3)); } BOOL CheckArray (int i) { if (flag == FALSE) return FALSE; switch (i) { case 1: return hb_arrayGetL(pArray, 1); case 2: return hb_arrayGetL(pArray, 2); case 3: return hb_arrayGetL(pArray, 3); default: return FALSE; } return FALSE; } // other functions in pure C (not HB_FUNC functions) that process pArray, for example: int set_cont () { cont = 0; if (CheckArray (1) == TRUE) cont++; if (CheckArray (2) == TRUE) cont++; if (CheckArray (3) == TRUE) cont++; return cont; } HB_FUNC (RET_CONT) { hb_retni (set_cont ()); } HB_FUNC (RELEASE_ARRAY_DATOS) { if (flag == TRUE) { hb_itemRelease (pArray); flag = FALSE; cont = 0; } } #pragma enddump ----- Original Message ----- From: Teo Fonrouge To: sr...@adinet.com.uy ; Harbour Project Main Developer List. Sent: Monday, April 12, 2010 11:47 AM Subject: Re: [Harbour] I have a problem with hb_arrayNew () Hello Claudio, On Apr 12, 2010, at 9:03 AM, sr...@adinet.com.uy wrote: Hi all, I have a doubt with the function hb_arrayNew When I create an array in C: #pragma begindump #include "hbapi.h" #include "hbapiitm.h" HB_FUNC (MyFunc) {............ ............. pArray = hb_itemNew (NULL); hb_arrayNew (pArray, size); .............. ............... } before the program ends I have necessarily to call: ( i guess that you mean "the function" instead of "the program" ) hb_itemRelease (pArray); to free the memory allocated? Yes or HARBOUR releases automatically? No, even MyFunc() needs to return the new array it needs to be released: HB_FUNC( MYFUNC ) { PHB_ITEM pArray = hb_itemNew( NULL ); <your operations with pArray here> hb_itemReturnRelease( pArray ); } Please read the following link, even it's based on Clipper 5.2 it perfectly applies to current Harbour too. Also please note that you need to use uppercase on the function name ( "MyFunc" is wrong ). best regards, Teo _______________________________________________ Harbour mailing list (attachment size limit: 40KB) Harbour@harbour-project.org http://lists.harbour-project.org/mailman/listinfo/harbour