Memory problem!

Hello everybody,

here are my needs :

I would like to store on RAM several data which come from several incoming packets. So, i save them in an ascii buffer. So, first time, data are copied in buffer. And next times, data are appended in buffer.

So, here are my sample code which introduce my needs :

ascii * ADText = "1234567890\0";               // Data received first (for e.g.)
u32 u32ADTextLgth = 11;            
ascii * ADText_2 = "0987654321\0";           // Data received next times (for e.g.)      
u32 u32ADText_2Lgth = 11; 


ascii * pu8GPRS_Buffer;                        // My data Buffer
u32 u32BufferLgth;                               // Data Buffer length

u32 u32Step = 0;

void PL_GPRS_Append(ascii * Data, u32 DataLen){

     ascii * Msg_2;
     if(u32BufferLgth <= 0){                                   // First time ...       
        pu8GPRS_Buffer = (ascii * ) adl_memGet(DataLen);       // Instanciate Buffer
        wm_strcpy(pu8GPRS_Buffer, Data);                       // Copy Data in my "Data Buffer"   
        u32BufferLgth = DataLen;                              // Save "Data Buffer" array length        
     else                                                     // Next times ...
        Msg_2 = (ascii * ) adl_memGet(u32BufferLgth);         // Instanciate a temporary Buffer
        wm_strcpy(Msg_2, pu8GPRS_Buffer);                     // Save "my Data Buffer" in this temporary buffer
        adl_memRelease(pu8GPRS_Buffer);                       // Release my data Buffer allocated memory
        pu8GPRS_Buffer = adl_memGet((DataLen + u32BufferLgth));  // Instanciate my "data Buffer" with the new size (in order to append data)
        wm_strcpy(pu8GPRS_Buffer, Msg_2);                     // re-copied data in "Data Buffer"
        wm_strcat(pu8GPRS_Buffer, Data);                        // append new data in my "Data Buffer"       
        u32BufferLgth = u32BufferLgth + DataLen ;             // Save my new Data Buffer array length
        adl_memRelease(Msg_2);                   // Release my temporary buffer

void TmrHndlr (u8 ID){
            case 0 :           
            case 1 :                // Append this data each time in my data buffer

            default :

void adl_main ( adl_InitType_e InitType )
      u32BufferLgth = 0;
     tTmrHdle = adl_tmrSubscribe(TRUE, 30, ADL_TMR_TYPE_100MS, TmrHndlr);

I just need a function which append data in RAM (as shown above). But, my function BL_GPRS_append doesn’t work. after 10 or 15 seconds, the module reset ! why ? there is any error in my code ? can someone help me ?! i think there is a stupid error (buffer length error because of \0 or another thing ??) but i don’t find it ! :angry:

or if you are a simple code which do the same thing don’t hesitate to post it !

You can easily copy and paste code in order to test it.

Thank you in advance for your help !!!


lool !

So, sorry for the trouble, but the main error is that there is NO ERROR in my code :blush: ! When, i posted the message i delete the line which cause the problem !

So, all its Ok ! :unamused: