]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - fractalnoise.c
every malloc/calloc/free converted to qmalloc/qfree with tracking (memstats command...
[xonotic/darkplaces.git] / fractalnoise.c
index c03039a74f62218f484ecd8f1416584c19a8f27b..e9899a47f84771e4bc3e22c2514ad20d514d0575 100644 (file)
@@ -1,5 +1,5 @@
 
-#include <stdlib.h>
+#include "quakedef.h"
 
 void fractalnoise(unsigned char *noise, int size, int startgrid)
 {
@@ -8,7 +8,8 @@ void fractalnoise(unsigned char *noise, int size, int startgrid)
 #define n(x,y) noisebuf[((y)&size1)*size+((x)&size1)]
        if (startgrid > size)
                startgrid = size;
-       noisebuf = calloc(size*size, sizeof(int));
+       noisebuf = qmalloc(size*size*sizeof(int));
+       memset(noisebuf, 0, size*size*sizeof(int));
 
        amplitude = 32767;
        // quick 1x1 case which the rest of the code can't handle
@@ -56,6 +57,6 @@ void fractalnoise(unsigned char *noise, int size, int startgrid)
        for (y = 0;y < size;y++)
                for (x = 0;x < size;x++)
                        *noise++ = (n(x,y) - min) * 255 / max;
-       free(noisebuf);
+       qfree(noisebuf);
 #undef n
 }
\ No newline at end of file