1
0
Fork 0
mirror of https://github.com/suchmememanyskill/TegraExplorer.git synced 2024-11-26 22:02:08 +00:00
TegraExplorer/source/tegraexplorer/utils/menuUtils.c

41 lines
1,022 B
C
Raw Permalink Normal View History

2020-05-04 12:55:26 +01:00
#include "menuUtils.h"
#include "../../utils/types.h"
#include "../common/types.h"
#include "../../mem/heap.h"
#include "utils.h"
void mu_clearObjects(menu_entry **menu){
if ((*menu) != NULL){
for (int i = 0; (*menu)[i].name != NULL; i++){
free((*menu)[i].name);
(*menu)[i].name = NULL;
}
free((*menu));
(*menu) = NULL;
}
}
void mu_createObjects(int size, menu_entry **menu){
(*menu) = calloc (size + 1, sizeof(menu_entry));
(*menu)[size].name = NULL;
}
2020-05-04 19:48:23 +01:00
int mu_countObjects(menu_entry *entries, u32 count, u8 propertyMask){
2020-05-04 12:55:26 +01:00
int amount = 0;
2020-05-04 19:48:23 +01:00
for (u32 i = 0; (count) ? i < count : entries[i].name != NULL; i++){
2020-05-04 12:55:26 +01:00
if (!(entries[i].property & propertyMask))
amount++;
}
return amount;
}
void mu_copySingle(char *name, u32 storage, u8 property, menu_entry *out){
if (out->name != NULL)
free(out->name);
utils_copystring(name, &out->name);
out->storage = storage;
out->property = property;
}