Advertisement

How do I dynamically...

Started by August 15, 2001 08:26 PM
3 comments, last by shdaga 23 years, 6 months ago
...allocate an array of RECTs for DX? The code I use looks like this:

RECT *mSpriteSourceRects;
...
mSpriteSourceRects = (RECT *)malloc(frames *(sizeof(RECT)));
  
is this correct? It doesnt seem to work logically in my program(but it will compile ok). Please shed some light on this, thanks Edited by - shdaga on August 15, 2001 9:27:24 PM
Here's a new dance everyone can do, do the Kirby:<(*.*<) <(^.^)> (>*.*)> <(^.^)> <(*.*<) (>^.^)>
Ah poop, never mind! I figured it out.
Here's a new dance everyone can do, do the Kirby:<(*.*<) <(^.^)> (>*.*)> <(^.^)> <(*.*<) (>^.^)>
Advertisement
If you''re using C++ (and who isn''t? I havenm''t seen a genuine C only compiler for a while) you should prefer new to malloc.

Then you get:

  RECT *mSpriteSourceRects;mSpriteSourceRects = new RECT[frames];  


which is much more readable, I find.

The only catch is making sure you call delete[] instead of delete but that''s pretty easy to figure out.

--


Games, Anime and more at GKWorld

Meet Bunny luv'' and the girls, ready to perform on your desktop just for you (warning: adult content).

All respect to the
new 
and
delete 
. A big "poo-poo" on
malloc 
and kin.

---
blahpers
---blahpers
would the delete for that look like...
  delete [] mSpriteSourceRects;  


??
Here's a new dance everyone can do, do the Kirby:<(*.*<) <(^.^)> (>*.*)> <(^.^)> <(*.*<) (>^.^)>

This topic is closed to new replies.

Advertisement