[Tinyos-commits] CVS: tinyos-1.x/tos/platform/pc external_comm.c,
1.40, 1.41
Phil Levis
scipio at users.sourceforge.net
Wed Nov 28 12:39:58 PST 2007
Update of /cvsroot/tinyos/tinyos-1.x/tos/platform/pc
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv13915
Modified Files:
external_comm.c
Log Message:
Fix a memory leak.
Index: external_comm.c
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/tos/platform/pc/external_comm.c,v
retrieving revision 1.40
retrieving revision 1.41
diff -C2 -d -r1.40 -r1.41
*** external_comm.c 7 Nov 2004 15:22:15 -0000 1.40
--- external_comm.c 28 Nov 2007 20:39:56 -0000 1.41
***************
*** 383,386 ****
--- 383,387 ----
unsigned char** replyMsg, int* replyLen) {
int ret = 0;
+ bool msg_handled = TRUE;
switch (msg->msgType) {
***************
*** 503,508 ****
--- 504,515 ----
dbg(DBG_SIM, "SIM: Enqueuing command event 0x%lx\n", (unsigned long)event);
TOS_queue_insert_event(event);
+ msg_handled = FALSE;
}
}
+
+ if (msg_handled == TRUE) {
+ free(msg);
+ free(payLoad);
+ }
return ret;
***************
*** 583,587 ****
int readTossimCommand(int clifd, int clidx) {
GuiMsg* msg;
! unsigned char *header;
char* payLoad = NULL;
int curlen = 0;
--- 590,594 ----
int readTossimCommand(int clifd, int clidx) {
GuiMsg* msg;
! unsigned char header[GUI_MSG_HEADER_LENGTH];
char* payLoad = NULL;
int curlen = 0;
***************
*** 594,598 ****
dbg_clear(DBG_SIM, "SIM: Reading command from client fd %d\n", clifd);
- header = (unsigned char *)malloc(GUI_MSG_HEADER_LENGTH);
msg = (GuiMsg*)malloc(sizeof(GuiMsg));
// read in header of GuiMsg
--- 601,604 ----
***************
*** 645,648 ****
--- 651,656 ----
else {
dbg(DBG_SIM|DBG_ERROR, "SIM: Received command for invalid mote: %i\n", (int)msg->moteID);
+ free(msg);
+ free(payLoad);
}
More information about the Tinyos-commits
mailing list