shithub: choc

Download patch

ref: af2add1cbef05bf05fe6a59f84975caabe0779c0
parent: 717ca7f67c77b09c9fc6f36936fbc6bdc4ff8e98
author: Simon Howard <[email protected]>
date: Fri Sep 26 12:27:32 EDT 2008

Use sizeof for size of types, rather than hard-coding the size.

Subversion-branch: /branches/raven-branch
Subversion-revision: 1289

--- a/src/heretic/p_setup.c
+++ b/src/heretic/p_setup.c
@@ -484,7 +484,7 @@
     }
 
 // build line tables for each sector    
-    linebuffer = Z_Malloc(total * 4, PU_LEVEL, 0);
+    linebuffer = Z_Malloc(total * sizeof(linebuffer_t *), PU_LEVEL, 0);
     sector = sectors;
     for (i = 0; i < numsectors; i++, sector++)
     {
--- a/src/heretic/r_data.c
+++ b/src/heretic/r_data.c
@@ -360,13 +360,13 @@
         InitThermo(spramount + numtextures + 6);
     }
 
-    textures = Z_Malloc(numtextures * 4, PU_STATIC, 0);
-    texturecolumnlump = Z_Malloc(numtextures * 4, PU_STATIC, 0);
-    texturecolumnofs = Z_Malloc(numtextures * 4, PU_STATIC, 0);
-    texturecomposite = Z_Malloc(numtextures * 4, PU_STATIC, 0);
-    texturecompositesize = Z_Malloc(numtextures * 4, PU_STATIC, 0);
-    texturewidthmask = Z_Malloc(numtextures * 4, PU_STATIC, 0);
-    textureheight = Z_Malloc(numtextures * 4, PU_STATIC, 0);
+    textures = Z_Malloc(numtextures * sizeof(texture_t *), PU_STATIC, 0);
+    texturecolumnlump = Z_Malloc(numtextures * sizeof(short *), PU_STATIC, 0);
+    texturecolumnofs = Z_Malloc(numtextures * sizeof(unsigned short *), PU_STATIC, 0);
+    texturecomposite = Z_Malloc(numtextures * sizeof(byte *), PU_STATIC, 0);
+    texturecompositesize = Z_Malloc(numtextures * sizeof(int), PU_STATIC, 0);
+    texturewidthmask = Z_Malloc(numtextures * sizeof(int), PU_STATIC, 0);
+    textureheight = Z_Malloc(numtextures * sizeof(fixed_t), PU_STATIC, 0);
 
     totalwidth = 0;
 
@@ -438,7 +438,7 @@
 //
 // translation table for global animation
 //
-    texturetranslation = Z_Malloc((numtextures + 1) * 4, PU_STATIC, 0);
+    texturetranslation = Z_Malloc((numtextures + 1) * sizeof(int), PU_STATIC, 0);
     for (i = 0; i < numtextures; i++)
         texturetranslation[i] = i;
 }
@@ -461,7 +461,7 @@
     numflats = lastflat - firstflat + 1;
 
 // translation table for global animation
-    flattranslation = Z_Malloc((numflats + 1) * 4, PU_STATIC, 0);
+    flattranslation = Z_Malloc((numflats + 1) * sizeof(int), PU_STATIC, 0);
     for (i = 0; i < numflats; i++)
         flattranslation[i] = i;
 }
@@ -485,9 +485,9 @@
     firstspritelump = W_GetNumForName("S_START") + 1;
     lastspritelump = W_GetNumForName("S_END") - 1;
     numspritelumps = lastspritelump - firstspritelump + 1;
-    spritewidth = Z_Malloc(numspritelumps * 4, PU_STATIC, 0);
-    spriteoffset = Z_Malloc(numspritelumps * 4, PU_STATIC, 0);
-    spritetopoffset = Z_Malloc(numspritelumps * 4, PU_STATIC, 0);
+    spritewidth = Z_Malloc(numspritelumps * sizeof(fixed_t), PU_STATIC, 0);
+    spriteoffset = Z_Malloc(numspritelumps * sizeof(fixed_t), PU_STATIC, 0);
+    spritetopoffset = Z_Malloc(numspritelumps * sizeof(fixed_t), PU_STATIC, 0);
 
     for (i = 0; i < numspritelumps; i++)
     {