From b590b550a13de8f5a7ee0f32e3e82c97ba1ca5c4 Mon Sep 17 00:00:00 2001 From: Cedric Roux <cedric.roux@eurecom.fr> Date: Wed, 13 Nov 2013 15:45:11 +0000 Subject: [PATCH] - Fixed memory leak for OMG - Fixed compiler warning for OMG git-svn-id: http://svn.eurecom.fr/openair4G/trunk@4385 818b1a75-f10b-46b9-bf7c-635c3b92a50f --- openair2/UTIL/OMG/common.c | 4 ++-- openair2/UTIL/OMG/storage_traci_OMG.c | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/openair2/UTIL/OMG/common.c b/openair2/UTIL/OMG/common.c index 573f70515f..cf92c645ed 100644 --- a/openair2/UTIL/OMG/common.c +++ b/openair2/UTIL/OMG/common.c @@ -73,7 +73,7 @@ mapping mob_type[] = //#endif NodePtr create_node(void) { NodePtr ptr; - ptr = malloc(sizeof(node_struct)); + ptr = calloc(1, sizeof(node_struct)); return ptr; } @@ -91,7 +91,7 @@ double randomGen(double a, double b){ MobilityPtr create_mobility(void) { MobilityPtr ptr; - ptr = malloc(sizeof(mobility_struct)); + ptr = calloc(1, sizeof(mobility_struct)); return ptr; } diff --git a/openair2/UTIL/OMG/storage_traci_OMG.c b/openair2/UTIL/OMG/storage_traci_OMG.c index 250877c64e..d143ab8410 100644 --- a/openair2/UTIL/OMG/storage_traci_OMG.c +++ b/openair2/UTIL/OMG/storage_traci_OMG.c @@ -181,7 +181,7 @@ char * readString(){ char *tmp = (char *)malloc(sizeof(char) * (len)); char *ret = tmp; // JHNOTE: added a pointer pointing at the head of the String //printf("OMG ready to readString of length %d \n",len); - for (i; i < len; i++) { + for (; i < len; i++) { *tmp++ = (char) readChar(); } *tmp++ = '\0'; // makes sure it's NUL terminated @@ -211,7 +211,7 @@ String_list readStringList(String_list vector){ descLen = len; String_list entry = NULL; - for (i; i < len; i++) { + for (; i < len; i++) { if (vector->string == NULL) { char *tmp = readString(); //printf("OMG - 1 SUMO ID: %s \n",tmp); @@ -370,15 +370,15 @@ double readDouble(){ if (bigEndian) { // network is big endian - int i=0; - for (i; i<8; ++i) + int i = 0; + for (; i<8; ++i) { p_value[i] = readChar(); } } else { int i=7; // network is big endian - for (i; i>=0; --i) { + for (; i>=0; --i) { p_value[i] = readChar(); } } @@ -391,13 +391,13 @@ void writeDouble(double value){ if (bigEndian) { int i=0; // network is big endian - for (i; i<8; ++i) + for (; i<8; ++i) { writeChar(p_value[i]); } } else {int i=7; // network is big endian - for (i; i>=0; --i) + for (; i>=0; --i) { writeChar(p_value[i]); } @@ -420,7 +420,7 @@ storage* writePacket (unsigned char* packet, int length){ int i = 0; - for(i; i < length; i++) { + for(; i < length; i++) { printf("in %d round \n",i); //storage *temp_ = (storage *)malloc(sizeof(storage)); -- GitLab