-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Am 2015-03-04 um 04:15 schrieb Alistair Leslie-Hughes:
if(entry->type == DPNA_DATATYPE_STRING_ANSI)
heap_free(entry->data.ansi);
else if(entry->type == DPNA_DATATYPE_STRING)
heap_free(entry->data.string);
else if(entry->type == DPNA_DATATYPE_BINARY)
heap_free(entry->data.binary);
This code is OK with me.
What I think Nikolai meant was that you don't need the if / else if / else if checks and can just call heap_free(entry->data.binary) (or heap_free(entry->data.ansi) or heap_free(entry->data.string)) regardless of the type because it's just a union.
However, there's a caveat, and this is why I think the code you have is reasonable: You don't want to free a non-pointer type (DPNA_DATATYPE_DWORD, DPNA_DATATYPE_GUID), so you need to check the type anyway. And if you have the code above or
if (type == STRING || type == BINARY || type == ANSI) free(data.binary)
doesn't really make a difference IMHO.