diff --git a/openair2/UTIL/OMG/common.c b/openair2/UTIL/OMG/common.c index 573f70515faa96c6ba4f0ad49c6e9ca5df39f7db..cf92c645ed6aa3ba3548b0d9d7c9fd9ac5010b41 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 250877c64e7af92cd11411784a9f309549ca8ad6..d143ab841056e49be1fe6a75cde4c02d913e6013 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));