* 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
master
Giel van Schijndel 2008-07-28 20:53:54 +00:00
parent 231866a510
commit 8eaf3bfa8b
2 changed files with 6 additions and 12 deletions

View File

@ -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
{

View File

@ -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