Stick to ckalloc/ckfree
authorpatthoyts <patthoyts>
Tue, 20 Jun 2006 13:12:18 +0000 (13:12 +0000)
committerpatthoyts <patthoyts>
Tue, 20 Jun 2006 13:12:18 +0000 (13:12 +0000)
ChangeLog
generic/udp_tcl.c

index a7023d21d4a890475a129c9a1c22219ce53787dd..3e59139843d807e1f83697e9e457cf610dd1a3bc 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,6 @@
 2006-06-20  Pat Thoyts  <patthoyts@users.sourceforge.net>
 
+       * generic/udp_tcl.c:  Stick to ckalloc/ckfree.
        * tests/udp-srv.test: Added new test file which runs a child
                              proces as a udp server.
        * tests/all.tcl:      Support 8.2 and 8.3 test package.
index fdeae4aee22a76d963bd4270c880245e669a0588..86b315a829a00aacba2e5727a572649569d65645 100644 (file)
@@ -580,11 +580,12 @@ UDP_CheckProc(ClientData data, int flags)
 #endif
             memset(&recvaddr, 0, socksize);
             
-            message = (char *)calloc(1, MAXBUFFERSIZE);
+            message = (char *)ckalloc(MAXBUFFERSIZE);
             if (message == NULL) {
-                UDPTRACE("calloc error\n");
+                UDPTRACE("ckalloc error\n");
                 exit(1);
             }
+            memset(message, 0, MAXBUFFERSIZE);
             
             actual_size = recvfrom(statePtr->sock, message, buffer_size, 0,
                                    (struct sockaddr *)&recvaddr, &socksize);
@@ -594,7 +595,7 @@ UDP_CheckProc(ClientData data, int flags)
                 UDPTRACE("UDP error - recvfrom %d\n", statePtr->sock);
                 ckfree(message);
             } else {
-                p = (PacketList *)calloc(1, sizeof(struct PacketList));
+                p = (PacketList *)ckalloc(sizeof(struct PacketList));
                 p->message = message;
                 p->actual_size = actual_size;
 #ifdef SIPC_IPV6
@@ -1064,13 +1065,13 @@ udpInput(ClientData instanceData, char *buf, int bufSize, int *errorCode)
         return 0;
     }
     memcpy(buf, packets->message, packets->actual_size);
-    free((char *) packets->message);
+    ckfree((char *) packets->message);
     UDPTRACE("udp_recv message\n%s", buf);
     bufSize = packets->actual_size;
     strcpy(statePtr->peerhost, packets->r_host);
     statePtr->peerport = packets->r_port;
     statePtr->packets = packets->next;
-    free((char *) packets);
+    ckfree((char *) packets);
     bytesRead = bufSize;
 #else /* ! WIN32 */
     socksize = sizeof(recvaddr);