From 8eaf3bfa8b83598728c35b091fe2fbb9f4c0eccc Mon Sep 17 00:00:00 2001 From: Giel van Schijndel Date: Mon, 28 Jul 2008 20:53:54 +0000 Subject: [PATCH] * Move constant MAX_DATA to messagedef.h * Use strdup() instead of malloc() + strcpy() * Remove unused enmurant VIEW_TYPES git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5694 4a71c877-e1ca-e34f-864e-861f7616d084 --- src/message.c | 13 +++---------- src/messagedef.h | 5 +++-- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/src/message.c b/src/message.c index f801491a9..78eebd058 100644 --- a/src/message.c +++ b/src/message.c @@ -41,9 +41,6 @@ #include "multiplay.h" -//max number of text strings or sequences for viewdata -#define MAX_DATA 4 - //array of pointers for the view data static VIEWDATA_LIST *apsViewData; @@ -522,13 +519,12 @@ VIEWDATA *loadViewData(const char *pViewMsgData, UDWORD bufferSize) psViewData->numText=(UBYTE)numText; //allocate storage for the name - psViewData->pName = malloc(strlen(name) + 1); + psViewData->pName = strdup(name); if (psViewData->pName == NULL) { ASSERT(false, "Out of memory"); return NULL; } - strcpy(psViewData->pName, name); debug(LOG_MSG, "Loaded %s", psViewData->pName); //allocate space for text strings @@ -599,13 +595,12 @@ VIEWDATA *loadViewData(const char *pViewMsgData, UDWORD bufferSize) if (strcmp(audioName, "0")) { //allocate space - psViewRes->pAudio = (char *) malloc(strlen(audioName) + 1); + psViewRes->pAudio = strdup(audioName); if (psViewRes->pAudio == NULL) { ASSERT(false, "loadViewData - Out of memory"); return NULL; } - strcpy(psViewRes->pAudio, audioName); } else { @@ -715,14 +710,12 @@ VIEWDATA *loadViewData(const char *pViewMsgData, UDWORD bufferSize) if (strcmp(audioName, "0")) { //allocate space - psViewReplay->pSeqList[dataInc].pAudio = (char *) malloc( - strlen(audioName) + 1); + psViewReplay->pSeqList[dataInc].pAudio = strdup(audioName); if (psViewReplay->pSeqList[dataInc].pAudio == NULL) { ASSERT(LOG_ERROR, "loadViewData - Out of memory"); return NULL; } - strcpy(psViewReplay->pSeqList[dataInc].pAudio, audioName); } else { diff --git a/src/messagedef.h b/src/messagedef.h index e6d6eb0ee..f836bef99 100644 --- a/src/messagedef.h +++ b/src/messagedef.h @@ -28,6 +28,9 @@ #include "lib/ivis_common/ivisdef.h" #include "positiondef.h" +/// max number of text strings or sequences for VIEWDATA +static const unsigned int MAX_DATA = 4; + typedef enum _message_type { MSG_RESEARCH, // Research message @@ -46,8 +49,6 @@ typedef enum _view_type VIEW_RPLX, // full screen view sequence - flic. extended format VIEW_BEACON, // Beacon message - - VIEW_TYPES, } VIEW_TYPE; typedef enum _prox_type