My only comment on this is thus: malloc() returns "void *" and that's what free() should be free'ing, so they should match.