void tsi_peer_destruct(tsi_peer *self) { if (self == NULL) return; if (self->properties != NULL) { tsi_peer_destroy_list_property(self->properties, self->property_count); self->properties = NULL; } self->property_count = 0; }
void tsi_peer_property_destruct(tsi_peer_property* property) { if (property->name != NULL) { free(property->name); } switch (property->type) { case TSI_PEER_PROPERTY_TYPE_STRING: if (property->value.string.data != NULL) { free(property->value.string.data); } break; case TSI_PEER_PROPERTY_TYPE_LIST: tsi_peer_destroy_list_property(property->value.list.children, property->value.list.child_count); default: /* Nothing to free. */ break; } *property = tsi_init_peer_property(); /* Reset everything to 0. */ }