/* Free a report and all registered fields. The field->usage and field->value table's are allocated behind the field, so we need only to free(field) itself.  */
static void hid_free_report(usbHidReport_t *report)
/* Free a report and all registered fields. The field->usage and field->value table's are allocated behind the field, so we need only to free(field) itself.  */
static void hid_free_report(usbHidReport_t *report)
{
    unsigned int n;
    for (n = 0; n < report->Maxfield; n++){
        if(report->Field[n]){
            if(report->Field[n]->usage){
                hal_free(report->Field[n]->usage);
                report->Field[n]->usage = NULL;
            }
            if(report->Field[n]->value){
                hal_free(report->Field[n]->value);
                report->Field[n]->value = NULL;
            }
            hal_free(report->Field[n]);
            report->Field[n] = NULL;
        }
    }
    hal_free(report);
    return;
}