57 lines
1.1 KiB
C++
57 lines
1.1 KiB
C++
/*
|
|
* Mr. 4th Dimention - Allen Webster
|
|
*
|
|
* 20.02.2016
|
|
*
|
|
* GUI system for 4coder
|
|
*
|
|
*/
|
|
|
|
// TOP
|
|
|
|
internal void
|
|
init_query_set(Query_Set *set){
|
|
Query_Slot *slot = set->slots;
|
|
int32_t i;
|
|
set->free_slot = slot;
|
|
set->used_slot = 0;
|
|
for (i = 0; i+1 < ArrayCount(set->slots); ++i, ++slot){
|
|
slot->next = slot + 1;
|
|
}
|
|
}
|
|
|
|
internal Query_Slot*
|
|
alloc_query_slot(Query_Set *set){
|
|
Query_Slot *slot = set->free_slot;
|
|
if (slot != 0){
|
|
set->free_slot = slot->next;
|
|
slot->next = set->used_slot;
|
|
set->used_slot = slot;
|
|
}
|
|
return(slot);
|
|
}
|
|
|
|
internal void
|
|
free_query_slot(Query_Set *set, Query_Bar *match_bar){
|
|
Query_Slot *slot = 0, *prev = 0;
|
|
|
|
for (slot = set->used_slot; slot != 0; slot = slot->next){
|
|
if (slot->query_bar == match_bar) break;
|
|
prev = slot;
|
|
}
|
|
|
|
if (slot){
|
|
if (prev){
|
|
prev->next = slot->next;
|
|
}
|
|
else{
|
|
set->used_slot = slot->next;
|
|
}
|
|
slot->next = set->free_slot;
|
|
set->free_slot = slot;
|
|
}
|
|
}
|
|
|
|
// BOTTOM
|
|
|