Re: static typing (Learning Cocoa Chapter 13)
Re: static typing (Learning Cocoa Chapter 13)
- Subject: Re: static typing (Learning Cocoa Chapter 13)
- From: "Erik M. Buck" <email@hidden>
- Date: Sat, 22 Sep 2001 23:16:21 -0500
Oh my god! If all rows are the same known size than that is _size_ too many
mallocs! For large _size_, calling malloc in a tight loop is extremely
expensive.
#include <stdlib.h>
#include <stdio.h>
typedef float heightMapRowType[100];
int main(int argc, char* argv[])
{
int size = 1000;
heightMapRowType *heightMap = (heightMapRowType *)malloc(size *
sizeof(heightMapRowType));
heightMap[10][10] = 100.0f;
printf("Szie of heightMap: %d\n", size * sizeof(heightMapRowType));
return 0;
}
----- Original Message -----