Feb 062009

Deleting memory and settings pointers back to null is done quite frequently when coding in c++ and VST development is no exception. The WDL library includes a few macros to help with this task but I added another.

IPlug/containers.h has the following lines

#define FREE_NULL(p) {free(p);p=0;}
#define DELETE_NULL(p) {delete(p); p=0;}

I added another line to free an array

#define FREE_NULL(p) {free(p); (p)=0;}
#define DELETE_NULL(p) {delete(p); (p)=0;}
#define DELETE_ARRAY(p) {delete[](p); (p)=0;}

  2 Responses to “IPlug: More robust delete macros”

  1. the if (p) checks are redundant, free/delete check them as well ;)

  2. Fixed

Sorry, the comment form is closed at this time.