Hi All,

I have a form with 2 fields with max limit of 15 chars. User enters the data 
and I send those data to our system. It sounds so simple. But whenever I use 
Field related functions and run the Gremlin, it crashes saying “Memory 
Leak”. I am using the latest POSE (4.1).However, if I comment out those 
functions and run the Gremlin, no Memory leaks. I went through newsgroup 
archives, documentation etc and I think I am following all the steps needed to 
grab the info from the field. I have enclosed part of my code which is causing 
the problem below. If anyone is interested, I’ll post part of the Memory leak 
Gremlin events. Any clues as to where I am going wrong???


static MemHandle txtNameH, txtPasswdH;
MemPtr  namePtr = NULL, passwdPtr = NULL;
Word        fldIndex;
char usrNameStr[20],  passwordStr[20];
    
//If Send button is clicked, send the command to the system 
//and display the response to the user.         
case SystemLoginSendButton: 
  MemSet(usrNameStr, sizeof(usrNameStr), 0);
  MemSet(passwordStr, sizeof(passwordStr), 0); 
                    
  usrNameFld = GetObjectPt(SystemLoginUsrNameField);               
ErrNonFatalDisplayIf(!usrNameFld,"Missing Field");
  unameLen_u16 = FldGetTextLength(usrNameFld);
                    
  passwdFld =  GetObjectPtr(SystemLoginPasswordField);
  ErrNonFatalDisplayIf(!passwdFld,"Missing Field");
  passwdLen_u16 = FldGetTextLength(passwdFld);
                    
  // if the username or password field is valid
  if (( usrNameFld != NULL ) && ( passwdFld != NULL )) {
                    
     txtNameH = FldGetTextHandle(usrNameFld);
                                                 
     if(txtNameH) {
        FldSetTextHandle(usrNameFld, NULL);                 
        namePtr = MemHandleLock(txtNameH);
     }
                                
     txtPasswdH = FldGetTextHandle(passwdFld);
     if ( txtPasswdH ) {
        FldSetTextHandle(passwdFld, NULL);
        passwdPtr = MemHandleLock(txtPasswdH);
     }

     if (( (unameLen_u16 > 0) && namePtr  ) &&                     ( 
(passwdLen_u16 > 0) && passwdPtr )) {
                                
//make sure you NULL terminate the usrNameStr string appropriately  
       StrNCopy(usrNameStr, namePtr, (sizeof(usrNameStr) - 1));
       StrCat(usrNameStr, "\r");
       usrNameStr[sizeof(usrNameStr) - 1] = NULL;
                   
       if(txtNameH) {
          err = MemHandleUnlock(txtNameH);
          ErrFatalDisplayIf(err, "Could not Unlock chunk in name field.");
         //FldSetTextHandle(usrNameFld, txtNameH );
       }
                                    
   //make sure you NULL terminate the Password string appropriately
       StrNCopy(passwordStr, passwdPtr, (sizeof(passwordStr) - 1));
       StrCat(passwordStr, "\r");
       passwordStr[sizeof(passwordStr) - 1] = NULL;
                                    
       if(txtPasswdH) {
        err = MemHandleUnlock(txtPasswdH);
                                
        ErrFatalDisplayIf(err, "Could not Unlock chunk in password field."); 
       }


Thanks a lot for your patience.

Anamika

-- 
For information on using the PalmSource Developer Forums, or to unsubscribe, 
please see http://www.palmos.com/dev/support/forums/

Reply via email to