As a followup, never "cleanup" the *data pointer. mIRC makes use of, and expects it to exist. in fact, it's probably a pointer to a statically allocated structure anyway, so it's not even cleanable.
Rule of thumb: you're only ever responsible to free() what you've malloc()'d... *data isn't your responsibility.