To add the same code works fine in VC++ when tested with maolloc.
I am getting a Bus error here which says that I am trying to access a
location which is neither in the ROM or
RAM.
Please do lemme know about it.
My basic requirement is to get a Char**(pointer to an array of pointers)
from a char *(a full string as got from the database).
I want to make this a Utility function later in my project so that it can be
re-used.In the below example I
am currently using it for my module.
Thx in advance..
Regards,
Vikas
----- Original Message -----
From: V...i...K...a...S <[EMAIL PROTECTED]>
To: Palm Developer Forum <[EMAIL PROTECTED]>
Sent: Wednesday, March 27, 2002 3:46 PM
Subject: MemoryProblems
> Hello All,
>
> Well am using the following code:-
> Inputstring :-"00001~VIKAS~VIKAS"
>
> extern Err getSalPersonStructPtrFromString(const char *
> p_Str_FormattedStr,SalPersonLoginInfoPtr p_SalStruct)
> {
> char * temp = NULL;
> char ** p_Str_Array = (char **)MemHandleNew(sizeof(char*));
> MemHandleLock((MemHandle)p_Str_Array);
> for(int i = 0 ,j = 0, k = 0; i < StrLen(p_Str_FormattedStr) ; i++)
> {
> if(i == 0)
> {
> temp = (char *)MemHandleNew(sizeof(char));
> UInt32 size = MemHandleSize((MemHandle)temp);
> MemHandleLock((MemHandle)temp);
> }
> if(p_Str_FormattedStr[i] =='~' )
> {
> *(temp +k) = '\0';
> p_Str_Array[j] = temp;
> MemHandleUnlock((MemHandle)temp);
> temp = NULL;
> temp = (char *)MemHandleNew(sizeof(char));
> MemHandleLock((MemHandle)temp);
> j++;
> k=0;
> }
> else
>
>
> *(temp+k ) = *(p_Str_FormattedStr+i); // ##################
> Memory Error at this line #############//
> k++;
> }
> }//End for
> p_SalStruct =
> (SalPersonLoginInfoPtr)MemPtrNew(sizeof(SalPersonLoginInfoStruct));
> p_SalStruct->p_str_ID = p_Str_Array[0];
> p_SalStruct->p_str_Name = p_Str_Array[1];
> p_SalStruct->p_str_Password = p_Str_Array[2];
> MemHandleUnlock((MemHandle)p_Str_Array);
> return errNone;
> }//End function
>
>
>
> Can anybody help me out as to why am i getting memory error at this
line..I
> hope my memory allocation
> is perfect.
>
>
> Regrads,
> Vikas Lakkashetti
>
>
> --
> For information on using the Palm Developer Forums, or to unsubscribe,
please see http://www.palmos.com/dev/support/forums/
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/support/forums/