|
|
11-20-2006
, 12:44
Re: Classes in plugins
|
#4
|
Stripper:Source is open source and uses new/delete extensively. As long as you keep track of your pointers, it's perfectly fine. Stripper tries to aggressively cache pointers (because 'new' is expensive) and I have made bugs with that before.
If you're new to memory management, a few tips:
1) "new" matches with "delete," the array version "new []" matches with "delete []," and "malloc"/"realloc" match with "free." Never mix an allocator with a mismatching deallocator.
2) "new," by definition, cannot return NULL (you can force it to, but I'm saying it just so you don't try to check the return value every time).
3) All three major deallocators (delete,delete[],free) will accept a NULL pointer and do nothing with it. This means you don't have to litter your code with "if" checks.
4) Always, always set invalid pointers to NULL. Just in case.
__________________
egg
|
|
|
|