foxygit / doom Log in
commit 1583812848e2704977df5a7a055610e5f63c8742
Author:     Simon Howard <fraggle@gmail.com>
AuthorDate: Tue Jan 27 21:21:56 2009 +0000
Commit:     Simon Howard <fraggle@gmail.com>
CommitDate: Tue Jan 27 21:21:56 2009 +0000

    Use sizeof() to calculate amounts to allocate, rather than hard-coded
    sizes.

    Subversion-branch: /branches/raven-branch
    Subversion-revision: 1431
---
 src/hexen/r_data.c | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/src/hexen/r_data.c b/src/hexen/r_data.c
index bfa1f2a9..3c2c652f 100644
--- a/src/hexen/r_data.c
+++ b/src/hexen/r_data.c
@@ -349,13 +349,13 @@ void R_InitTextures(void)
     }
     numtextures = numtextures1 + numtextures2;

-    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(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;

@@ -392,8 +392,8 @@ void R_InitTextures(void)
                 I_Error("R_InitTextures: Missing patch in texture %s",
                         texture->name);
         }
-        texturecolumnlump[i] = Z_Malloc(texture->width * 2, PU_STATIC, 0);
-        texturecolumnofs[i] = Z_Malloc(texture->width * 2, PU_STATIC, 0);
+        texturecolumnlump[i] = Z_Malloc(texture->width * sizeof(short), PU_STATIC, 0);
+        texturecolumnofs[i] = Z_Malloc(texture->width * sizeof(short), PU_STATIC, 0);
         j = 1;
         while (j * 2 <= texture->width)
             j <<= 1;
@@ -420,7 +420,7 @@ void R_InitTextures(void)
 //
 // 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;
 }
@@ -443,7 +443,7 @@ void R_InitFlats(void)
     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;
 }
@@ -467,9 +467,9 @@ void R_InitSpriteLumps(void)
     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++)
     {