That code does not even remotely do what you think it does. For starters, array indices start at 0 and not at 1. But even worse, malloc(sys_malloc(...)) is absolutely nonsensical, use either one or the other! Both allocate memory and return a pointer to it, so by feeding the result of sys_malloc() to malloc() means you tell malloc() to allocate a memory chunk the size of whatever value the pointer has, so you might be easily allocating a gigabyte or more here. And on top of that, you leak the memory returned by sys_malloc() (obviously only a tiny a fraction of what the malloc() could potentially allocate)


Shitlord by trade and passion. Graphics programmer at Laminar Research.
I write blog posts at feresignum.com