Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

C memory management

Name: Anonymous 2011-02-12 5:42

Hey /prog, I'm teaching myself C by writing a roguelike and I noticed that C uses manual memory management for creating objects in the heap. I was wondering if the C-gods could lend me some advice on how to proceed with this:

I want to write a roguelike with thousands of NPCs, every NPC is a really small piece of data which does not contain any pointers (position, stats, behavior... probably ends up being a few bytes). NPCs would spawn and die constantly. How would I go about managing the memory for this?

• malloc and free individual NPCs
• Boehm-Demers-Weiser conservative garbage collector
• malloc a big chunk of memory and build some kind of memory manager on top of it (are there techniques for this?)

Please advice.

Name: Anonymous 2011-02-12 10:44

>>9
U MENA >>4, which, incidentally, was myself.

What I had in mind was basically an std::vector implementation in C.

Your insinuation that your shit is "an example of what code might look like according to" my suggestion is quite frankly insulting.

I did not praise your "advice" about documenting the code because it's fucking obvious, but OK, that's a good advice.

The code you wrote on the other hand is horrible. What's even more terrifying is that you don't understand this and are surprised at the reaction. Like, it's just a quick hack, why I'm so worked up about it?

Well, you see, it's as if you were hungry and decided to eat some feces, "it's just a quick snack, what's up?"

There's no amount of "quickness" that can excuse this shit.

I repeat, your brain is seriously damaged by C, the retarded "let's just pass a pointer, then scan ahead to find the end" attitude in particular. I forbid you to write any more C before you learn to express yourself in a less retarded manner in C++.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List