summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoland Bär <roland@verifysoft.de>2008-02-20 11:40:28 +0100
committerJoel Bosveld <joel@joel-desktop.(none)>2008-02-20 22:10:30 +0900
commit0b2d6214b48a788d4c71f6c0024861443fdc55ff (patch)
treec53493408fc353e476a5c3996609be7506350f8b
parentf9a4809a119e5f45075082dcab6f938e610724a6 (diff)
downloadcubedbus-0b2d6214b48a788d4c71f6c0024861443fdc55ff.tar.gz
cubedbus-0b2d6214b48a788d4c71f6c0024861443fdc55ff.tar.bz2
Accumulated patches
-rw-r--r--cubedbus.c23
-rw-r--r--cubedbusModel.c.in53
-rw-r--r--cubedbusParticle.c.in2
-rw-r--r--particleFx/emitter.c.in4
-rw-r--r--particleFx/move.c.in2
5 files changed, 61 insertions, 23 deletions
diff --git a/cubedbus.c b/cubedbus.c
index 849ed8e..e13a429 100644
--- a/cubedbus.c
+++ b/cubedbus.c
@@ -108,7 +108,10 @@ cubedbusAddObject (CompDisplay *d,
{
while(1)
{
- if(objptr == NULL) return FALSE;
+ if(objptr == NULL) {
+ free(cubedbusName);
+ return FALSE;
+ }
if(!strcmp(objptr->name,cubedbusName->string[i]))
{
@@ -127,6 +130,7 @@ cubedbusAddObject (CompDisplay *d,
if( (strcmp(cubedbusName->string[i],"") == 0) || ( strlen(cubedbusName->string[i]) >= 16))
{
compLogMessage (NULL,"cubedbus",CompLogLevelError, "error with name");
+ free(cubedbusName);
return FALSE;
}
@@ -167,15 +171,20 @@ cubedbusDeleteObject (CompDisplay *d,
CubedbusName *cubedbusName = malloc (sizeof(CubedbusName));
int i;
- if(!cubedbusGetName( getStringOptionNamed(option,nOption,"name",""), cubedbusName )) return FALSE;
-
+ if(!cubedbusGetName( getStringOptionNamed(option,nOption,"name",""), cubedbusName )) {
+ free(cubedbusName);
+ return FALSE;
+ }
/* sets the head pointer correctly */
for(i=0;i<cubedbusName->n -1 ;i++) /* stop 1 before the object to be created */
{
while(1)
{
- if(objptr == NULL) return FALSE;
+ if(objptr == NULL) {
+ free(cubedbusName);
+ return FALSE;
+ }
if(!strcmp(objptr->name, cubedbusName->string[i]))
{
@@ -190,7 +199,10 @@ cubedbusDeleteObject (CompDisplay *d,
while(1)
{
- if(objptr==NULL) return false;
+ if(objptr==NULL) {
+ free(cubedbusName);
+ return false;
+ }
if(!strcmp(objptr->name,cubedbusName->string[i]))
{
if(objptr->prev != NULL) objptr->prev->next=objptr->next;
@@ -202,6 +214,7 @@ cubedbusDeleteObject (CompDisplay *d,
if(objptr->next != NULL) objptr->next->prev=objptr->prev;
+ free(cubedbusName);
return (objptr->delfunc) (objptr);
}
objptr=objptr->next;
diff --git a/cubedbusModel.c.in b/cubedbusModel.c.in
index d44c4d4..471d213 100644
--- a/cubedbusModel.c.in
+++ b/cubedbusModel.c.in
@@ -16,7 +16,7 @@ static bool cubedbusAddModelObject (CubedbusObject *obj, CompOption *option, int
static bool cubedbusDrawVBOModel (CubedbusObject *obj, float *vertex, float *normal);
static int
-addNumToString (char *, unsigned int, int, char *, char *, unsigned int, unsigned int);
+addNumToString (char **, unsigned int, int, char *, char *, unsigned int, unsigned int);
static int
addVertex (unsigned int **indices, int nUniqueIndices, int iTexture, int iNormal);
@@ -206,7 +206,10 @@ cubedbusAddModelObject (CubedbusObject *obj, CompOption *option, int nOption)
char * filename = malloc (size*sizeof(char));
-
+ if (!filename) {
+ return FALSE;
+ }
+
memcpy (filename, baseFilename, (lenBaseFilename+1)*sizeof(char));
filename[lenBaseFilename]='\0';
@@ -222,6 +225,9 @@ cubedbusAddModelObject (CubedbusObject *obj, CompOption *option, int nOption)
{
lenBaseFilename+=4;
filename = realloc (filename, (lenBaseFilename+1)*sizeof(char));
+ if (!filename) {
+ return FALSE;
+ }
filename[lenBaseFilename-4]='.';
filename[lenBaseFilename-3]='o';
filename[lenBaseFilename-2]='b';
@@ -241,7 +247,7 @@ cubedbusAddModelObject (CubedbusObject *obj, CompOption *option, int nOption)
do {
if (animation)
- size = addNumToString (filename, size, lenBaseFilename, pre, post, startFileNum+fileCounter, maxNumZeros);
+ size = addNumToString (&filename, size, lenBaseFilename, pre, post, startFileNum+fileCounter, maxNumZeros);
fp = fopen(filename, "r");
if (fp!=NULL) {
@@ -291,13 +297,19 @@ cubedbusAddModelObject (CubedbusObject *obj, CompOption *option, int nOption)
/* First pass - count how much data we need to store */
if (animation)
- size = addNumToString (filename, size, lenBaseFilename, pre, post, startFileNum+fc, maxNumZeros);
+ size = addNumToString (&filename, size, lenBaseFilename, pre, post, startFileNum+fc, maxNumZeros);
fp = fopen(filename, "r");
if (fp == NULL)
{
compLogMessage(obj->s->display, "cubedbus", CompLogLevelWarn,
"Failed to open model file - %s", filename);
+ free(normal);
+ free(tmpIndices);
+ free(texture);
+ free(vertex);
+ free(nMtllib);
+ free(mtllib);
return FALSE;
}
@@ -318,7 +330,7 @@ cubedbusAddModelObject (CubedbusObject *obj, CompOption *option, int nOption)
return FALSE;
}
while (strline!=NULL) {
- if (!strcmp(tmpType, "")) {
+ if (tmpType && !strcmp(tmpType, "")) {
tmpType=strsep(&strline, delim);
}
else break;
@@ -366,6 +378,13 @@ cubedbusAddModelObject (CubedbusObject *obj, CompOption *option, int nOption)
{
compLogMessage(obj->s->display, "cubedbus", CompLogLevelWarn,
"Failed to open model file");
+ free(normal);
+ free(tmpIndices);
+ free(texture);
+ free(vertex);
+ free(nMtllib);
+ free(mtllib);
+
return FALSE;
}
@@ -425,7 +444,7 @@ cubedbusAddModelObject (CubedbusObject *obj, CompOption *option, int nOption)
return FALSE;
}
while (strline!=NULL) {
- if (!strcmp(tmpType, "")) {
+ if (tmpType && !strcmp(tmpType, "")) {
tmpType=strsep(&strline, delim);
}
else break;
@@ -508,6 +527,13 @@ cubedbusAddModelObject (CubedbusObject *obj, CompOption *option, int nOption)
{
compLogMessage(obj->s->display, "cubedbus", CompLogLevelWarn,
"Failed to open model file");
+ free(normal);
+ free(tmpIndices);
+ free(texture);
+ free(vertex);
+ free(nMtllib);
+ free(mtllib);
+
return FALSE;
}
@@ -536,7 +562,7 @@ cubedbusAddModelObject (CubedbusObject *obj, CompOption *option, int nOption)
return FALSE;
}
while (strline!=NULL) {
- if (!strcmp(tmpType, "")) {
+ if (tmpType && !strcmp(tmpType, "")) {
tmpType=strsep(&strline, delim);
}
else break;
@@ -605,7 +631,7 @@ cubedbusAddModelObject (CubedbusObject *obj, CompOption *option, int nOption)
if (strline==NULL || tmpType==NULL) continue;
while (strline!=NULL) {
- if (!strcmp(tmpType, "")) {
+ if (tmpType && !strcmp(tmpType, "")) {
tmpType=strsep(&strline, delim);
}
else break;
@@ -618,7 +644,7 @@ cubedbusAddModelObject (CubedbusObject *obj, CompOption *option, int nOption)
if (tmpType==NULL) break;
while (strline!=NULL) {
- if (!strcmp(tmpType, "")) {
+ if (tmpType && !strcmp(tmpType, "")) {
tmpType=strsep(&strline, delim);
}
else break;
@@ -1025,8 +1051,7 @@ cubedbusAddModelObject (CubedbusObject *obj, CompOption *option, int nOption)
if (tmpIndices)
free (tmpIndices);
- if (filename)
- free (filename);
+ free (filename);
if (oldStrline)
free (oldStrline);
@@ -1035,10 +1060,11 @@ cubedbusAddModelObject (CubedbusObject *obj, CompOption *option, int nOption)
}
static int
-addNumToString (char * s, unsigned int size, int offset, char *pre, char *post, unsigned int x, unsigned int maxNumZeros)
+addNumToString (char ** sp, unsigned int size, int offset, char *pre, char *post, unsigned int x, unsigned int maxNumZeros)
{
int c = 0;
int numZeros = 0;
+ char *s = *sp;
int i = x;
while (i!=0) {
@@ -1052,7 +1078,7 @@ addNumToString (char * s, unsigned int size, int offset, char *pre, char *post,
int j = offset+strlen(pre)+c+numZeros+strlen(post)+4+1;
if (j>size) {
size = j;
- s = (char *) realloc(s, size*sizeof(char));
+ s=*sp = (char *) realloc(*sp, size*sizeof(char));
}
for (j=0; j<strlen(pre); j++)
@@ -1074,7 +1100,6 @@ addNumToString (char * s, unsigned int size, int offset, char *pre, char *post,
s[offset+strlen(pre)+c+numZeros+strlen(post)+3] = 'j';
s[offset+strlen(pre)+c+numZeros+strlen(post)+4] = '\0';
-
return size;
}
diff --git a/cubedbusParticle.c.in b/cubedbusParticle.c.in
index b1e9f9c..e787a31 100644
--- a/cubedbusParticle.c.in
+++ b/cubedbusParticle.c.in
@@ -178,7 +178,7 @@ cubedbusAddParticleObject (CubedbusObject *obj, CompOption *option, int nOption)
particle->dataSets[6].nData=3;
particle->dataSets[6].data = malloc (sizeof (CompFxParticleEmitterParticleData) * particle->dataSets[6].nData);
- particle->dataSets[6].name= malloc (sizeof (char) * 12);
+ particle->dataSets[6].name= malloc (sizeof (char) * 13);
strcpy (particle->dataSets[6].name, "acceleration");
particle->dataSets[6].data[0].compFxParticleEmitterAddDataProc = &compFxParticleEmitterAddDataStandard;
particle->dataSets[6].data[1].compFxParticleEmitterAddDataProc = &compFxParticleEmitterAddDataStandard;
diff --git a/particleFx/emitter.c.in b/particleFx/emitter.c.in
index 6607aa6..fed538b 100644
--- a/particleFx/emitter.c.in
+++ b/particleFx/emitter.c.in
@@ -90,7 +90,7 @@ compFxParticleInitiate (CompFxParticle *particle, CompFxParticleEmitterParticleD
particle->nDataSets=data->nDataSets;
particle->dataSets = malloc (sizeof (CompFxParticleDataSet) * particle->nDataSets);
- if(particle->dataSets == NULL); /* XXX error XXX */
+ if(particle->dataSets == NULL) return; /* XXX error XXX */
for(i=0; i < particle->nDataSets;i++)
{
@@ -170,7 +170,7 @@ compFxParticleEmitterStepColour (CompFxParticleEmitter *emitter)
strcpy (particle->dataSets[5].name, "dList");
particle->dataSets[5].data = malloc (sizeof (CompFxParticleData) * 1);
- particle->dataSets[6].name= malloc (sizeof (char) * 12);
+ particle->dataSets[6].name= malloc (sizeof (char) * 13);
strcpy (particle->dataSets[6].name, "acceleration");
particle->dataSets[6].data = malloc (sizeof (CompFxParticleData) * 3);
diff --git a/particleFx/move.c.in b/particleFx/move.c.in
index 4470b3e..0a92c26 100644
--- a/particleFx/move.c.in
+++ b/particleFx/move.c.in
@@ -7,7 +7,7 @@ compFxParticleMoveConstantAcceleration (CompFxParticle *particle)
CompFxParticleDataSet *velocity = compFxParticleFindDataSet ("velocity", particle, 0);
CompFxParticleDataSet *acceleration = compFxParticleFindDataSet ("acceleration", particle, 0);
- if(position==NULL || velocity==NULL) return;
+ if(position==NULL || velocity==NULL || acceleration==NULL) return;
position->data[0].f += velocity->data[0].f; /* x += vx */
position->data[1].f += velocity->data[1].f; /* y += vy */