ayttm-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Ayttm-commits] CVS: ayttm/modules/msn2/libmsn2 msn_bittybits.C,1.15,1.1


From: Philip S Tellis <address@hidden>
Subject: [Ayttm-commits] CVS: ayttm/modules/msn2/libmsn2 msn_bittybits.C,1.15,1.16 msn_core.C,1.50,1.51 msn_core.h,1.15,1.16
Date: Thu, 27 Mar 2003 07:57:11 -0500

Update of /cvsroot/ayttm/ayttm/modules/msn2/libmsn2
In directory subversions:/tmp/cvs-serv1541/modules/msn2/libmsn2

Modified Files:
        msn_bittybits.C msn_core.C msn_core.h 
Log Message:
Fix memory leaks.  Now if only I can do that for myself

Index: msn_bittybits.C
===================================================================
RCS file: /cvsroot/ayttm/ayttm/modules/msn2/libmsn2/msn_bittybits.C,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- msn_bittybits.C     26 Mar 2003 17:23:58 -0000      1.15
+++ msn_bittybits.C     27 Mar 2003 12:57:08 -0000      1.16
@@ -251,7 +251,8 @@
 
   if(s==NULL) { return NULL; }
 
-  retval=strdup(s);
+  retval=new char[strlen(s)+1];
+  strcpy(retval, s);
   return retval;
 }
 

Index: msn_core.C
===================================================================
RCS file: /cvsroot/ayttm/ayttm/modules/msn2/libmsn2/msn_core.C,v
retrieving revision 1.50
retrieving revision 1.51
diff -u -r1.50 -r1.51
--- msn_core.C  26 Mar 2003 17:23:58 -0000      1.50
+++ msn_core.C  27 Mar 2003 12:57:08 -0000      1.51
@@ -318,7 +318,10 @@
         userdata * newuser=new userdata();
         newuser->username=msn_permstring(args[6]);
         newuser->friendlyname=msn_decode_URL(msn_permstring(args[6]));
-       newuser->groups=msn_permstring(args[8]);
+       if(numargs>8)
+               newuser->groups=msn_permstring(args[8]);
+       else
+               newuser->groups=NULL;
        ext_got_friend(newuser->username, newuser->groups);
         msn_add_to_llist(info->fl, newuser);
         if(atoi(args[4])==atoi(args[5]))
@@ -564,7 +567,7 @@
     snprintf(buf, sizeof(buf), "CAL %d %s\r\n", next_trid, auth->rcpt);
     write(conn->sock, buf, strlen(buf));
 
-    delete auth->rcpt;
+    delete [] auth->rcpt;
     auth->rcpt=NULL;
 
     next_trid++;
@@ -858,7 +861,7 @@
   if(!strcmp(content, "text/plain"))
   {
     message * msg=new message;
-    msg->header=strdup(mime);
+    msg->header=msn_permstring(mime);
     msg->body=(body != NULL) ? strdup(body):strdup("");
     msg->font=NULL;
     msg->content=msn_find_in_mime(mime, "Content-Type"); // include any 
"charset=" I've chopped off
@@ -890,7 +893,7 @@
       printf("Unknown content-type: \"%s\"\n", content);
     
   }
-  delete content;
+  delete [] content;
   free(msg);
 }
 

Index: msn_core.h
===================================================================
RCS file: /cvsroot/ayttm/ayttm/modules/msn2/libmsn2/msn_core.h,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- msn_core.h  26 Mar 2003 16:18:50 -0000      1.15
+++ msn_core.h  27 Mar 2003 12:57:08 -0000      1.16
@@ -26,7 +26,7 @@
   public:
   char * c;
   char_data(char * tc) { c=tc; }
-  ~char_data() { if(c!=NULL) { delete c; } }
+  ~char_data() { if(c!=NULL) { delete [] c; } }
 };
 
 class message : public llist_data // This class encapsulates all that you need 
to know (tm) about a MSG
@@ -54,9 +54,9 @@
          body=NULL; }
          
   ~message() { 
-         if (header) free(header);
-         if (font) free(font);
-         if (content) free(content);
+         if (header) delete [] header;
+         if (font) delete [] font;
+         if (content) delete [] content;
          if (body) free(body);
          header=NULL; 
          font=NULL; 
@@ -71,7 +71,7 @@
   char * friendlyname;
   char * groups;
   userdata() { username=friendlyname=NULL; }
-  ~userdata() { if(username!=NULL) { delete username; } if(friendlyname!=NULL) 
{ delete friendlyname; } if(groups!=NULL) { delete groups; } }
+  ~userdata() { if(username!=NULL) { delete [] username; } 
if(friendlyname!=NULL) { delete [] friendlyname; } if(groups!=NULL) { delete [] 
groups; } }
 };
 
 class authdata
@@ -121,7 +121,7 @@
   char * password;
 
   authdata_NS() { username=password=NULL; }
-  ~authdata_NS() { if(username!=NULL) { delete username; delete password; } }
+  ~authdata_NS() { if(username!=NULL) { delete [] username; delete [] 
password; } }
 };
 
 class authdata_SB : public authdata
@@ -136,7 +136,7 @@
 
   authdata_SB() { username=sessionID=cookie=NULL; }
   ~authdata_SB()
-  { if(username!=NULL) { delete username; delete sessionID; delete cookie; } }
+  { if(username!=NULL) { delete [] username; delete [] sessionID; delete [] 
cookie; } }
 };
 
 class invitation : public llist_data
@@ -149,7 +149,7 @@
   int cancelled;
   
   invitation() { cookie=other_user=NULL; cancelled=0;}
-  ~invitation() { if(cookie!=NULL) { delete cookie; } if(other_user!=NULL) { 
delete other_user; } }
+  ~invitation() { if(cookie!=NULL) { delete [] cookie; } if(other_user!=NULL) 
{ delete [] other_user; } }
 };
 
 #define APP_FTP 1       // NOTE: this is MSN file transfer, which is NOTHING 
to do with ordinary FTP!
@@ -164,7 +164,7 @@
 
   invitation_ftp() { filename=NULL;}
   ~invitation_ftp()
-    { if(filename!=NULL) { delete filename; } }
+    { if(filename!=NULL) { delete [] filename; } }
 };
 
 class invitation_voice : public invitation
@@ -174,7 +174,7 @@
 
   invitation_voice() { sessionid=NULL; }
   ~invitation_voice()
-    { if(sessionid!=NULL) { delete sessionid; } }
+    { if(sessionid!=NULL) { delete [] sessionid; } }
 };
 
 
@@ -193,8 +193,8 @@
   authdata_FTP() { cookie=username=NULL; inv=NULL; fd=-1; 
bytes_done=num_ignore=connected=0; }
   ~authdata_FTP()
   {
-    if(cookie!=NULL) { delete cookie; }
-    if(username!=NULL) { delete username; }
+    if(cookie!=NULL) { delete [] cookie; }
+    if(username!=NULL) { delete [] username; }
     if(inv!=NULL) { delete inv; }
   }
 };
@@ -366,7 +366,7 @@
   char * password;
   connectinfo() { username=password=NULL; }
   ~connectinfo()
-  { if(username!=NULL) { delete username; } if(password!=NULL) { delete 
password; } }
+  { if(username!=NULL) { delete [] username; } if(password!=NULL) { delete [] 
password; } }
 };
 
 void msn_connect_2(msnconn * conn, int trid, char ** args, int numargs, 
callback_data * data);





reply via email to

[Prev in Thread] Current Thread [Next in Thread]