Game Development Community

Allocating....

by Ricky Taylor · in Torque Game Builder · 11/02/2005 (4:47 pm) · 3 replies

How do I allocate something correctly with t2d....

I try U8 *byte = new U8[2];

and then delete byte;

and I get errors.... Im a C# fanboy and I only took a few online tutorials for c++....

Thanks in advanced.

#1
11/03/2005 (11:14 am)
Hard to help you on your errors if you don't post what they are. ;)

Are you getting "array alloc mismatch?" If so, then you'll probably find that you're deleting the array allocation using...
delete byte;
... instead of...
delete [] byte;

If this is your problem then here's how you do it with single/multiple allocations...
U8 *singleItem = new U8;
delete singleItem;

U8* multipleItems = new U8[100];
delete [] multipleItems;

Hope this helps,

- Melv.
#2
11/03/2005 (2:15 pm)
Grrr... This is too good to be true! Thanks Melv! =)
#3
11/04/2005 (12:10 am)
No problem; happy T2D'ing. :)

- Melv.