reshandle_t rs_texture_queueload(const char* tex_filepath, uint first_mipidx, int srgb, reshandle_t override_hdl) { /* if we have an override handle, check in existing queue and see if it's already exists */ if (override_hdl != INVALID_HANDLE && rs_loadqueue_search(override_hdl) != NULL) return override_hdl; reshandle_t hdl = rs_add_resource(tex_filepath, g_rs.blank_tex, override_hdl, rs_texture_unload); if (hdl == INVALID_HANDLE) return hdl; struct rs_load_data* ldata = (struct rs_load_data*)mem_pool_alloc(&g_rs.load_data_pool); ASSERT(ldata); memset(ldata, 0x00, sizeof(struct rs_load_data)); str_safecpy(ldata->filepath, sizeof(ldata->filepath), tex_filepath); ldata->hdl = hdl; ldata->type = RS_RESOURCE_TEXTURE; ldata->params.tex.first_mipidx = first_mipidx; ldata->params.tex.srgb = srgb; ldata->reload = (override_hdl != INVALID_HANDLE); /* push to load list */ list_addlast(&g_rs.load_list, &ldata->lnode, ldata); return hdl; }
set_t *set_intersection(set_t *a, set_t *b) { if (a->cmpfunc != b->cmpfunc) { fatal_error("intersection of incompatible sets"); return NULL; } /* Merge the two sets into a sorted list, keeping common elements only */ list_t *result = list_create(a->cmpfunc); treenode_t *na = a->first; treenode_t *nb = b->first; while (na != nullNode && nb != nullNode) { int cmp = a->cmpfunc(na->elem, nb->elem); if (cmp < 0) { /* Occurs in a only */ na = na->next; } else if (cmp > 0) { /* Occurs in b only */ nb = nb->next; } else { /* Occurs in both a and b, keep this one */ list_addlast(result, na->elem); na = na->next; nb = nb->next; } } /* Convert the sorted list into a balanced tree */ return buildset(result, a->cmpfunc); }
set_t *set_union(set_t *a, set_t *b) { if (a->cmpfunc != b->cmpfunc) { fatal_error("union of incompatible sets"); return NULL; } /* Merge the two sets into a sorted list */ list_t *result = list_create(a->cmpfunc); treenode_t *na = a->first; treenode_t *nb = b->first; while (na != nullNode && nb != nullNode) { int cmp = a->cmpfunc(na->elem, nb->elem); if (cmp < 0) { /* Occurs in a only */ list_addlast(result, na->elem); na = na->next; } else if (cmp > 0) { /* Occurs in b only */ list_addlast(result, nb->elem); nb = nb->next; } else { /* Occurs in both a and b */ list_addlast(result, na->elem); na = na->next; nb = nb->next; } } /* Plus what's left of the remaining set (either a or b) */ for (; na != nullNode; na = na->next) { list_addlast(result, na->elem); } for (; nb != nullNode; nb = nb->next) { list_addlast(result, nb->elem); } /* Convert the sorted list into a balanced tree */ return buildset(result, a->cmpfunc); }
set_t *set_copy(set_t *set) { /* Insert all our elements into a list in sorted order */ list_t *list = list_create(set->cmpfunc); treenode_t *n; for (n = set->first; n != nullNode; n = n->next) { list_addlast(list, n->elem); } /* Convert the sorted list into a balanced tree */ return buildset(list, set->cmpfunc); }
INLINE struct prf_node* prf_create_node(const char* name, const char* file, uint line, struct prf_node* parent) { struct prf_samples* s = (struct prf_samples*)g_prf.samples_back; struct prf_node* node = (struct prf_node*)mem_stack_alloc(&s->alloc, sizeof(struct prf_node), MID_PRF); ASSERT(node); memset(node, 0x00, sizeof(struct prf_node)); strcpy(node->name, name); /* add to hierarchy */ if (parent != NULL) { node->parent = parent; list_addlast(&parent->childs, &node->l, node); } else { list_addlast(&s->nodes, &node->l, node); } return node; }
set_t *set_difference(set_t *a, set_t *b) { if (a->cmpfunc != b->cmpfunc) { fatal_error("difference between incompatible sets"); return NULL; } /* Merge the two sets into a sorted list, keeping only elements that occur in a and not b */ list_t *result = list_create(a->cmpfunc); treenode_t *na = a->first; treenode_t *nb = b->first; while (na != nullNode && nb != nullNode) { int cmp = a->cmpfunc(na->elem, nb->elem); if (cmp < 0) { /* Occurs in a only, keep this one */ list_addlast(result, na->elem); na = na->next; } else if (cmp > 0) { /* Occurs in b only */ nb = nb->next; } else { /* Occurs in both a and b */ na = na->next; nb = nb->next; } } /* Plus what's left of a */ for (; na != nullNode; na = na->next) { list_addlast(result, na->elem); } /* Convert the sorted list into a balanced tree */ return buildset(result, a->cmpfunc); }
reshandle_t rs_animreel_queueload(const char* reel_filepath, reshandle_t override_hdl) { if (override_hdl != INVALID_HANDLE && rs_loadqueue_search(override_hdl) != NULL) return override_hdl; reshandle_t hdl = rs_add_resource(reel_filepath, NULL, override_hdl, rs_animreel_unload); if (hdl == INVALID_HANDLE) return hdl; struct rs_load_data* ldata = (struct rs_load_data*)mem_pool_alloc(&g_rs.load_data_pool); ASSERT(ldata); memset(ldata, 0x00, sizeof(struct rs_load_data)); str_safecpy(ldata->filepath, sizeof(ldata->filepath), reel_filepath); ldata->hdl = hdl; ldata->type = RS_RESOURCE_ANIMREEL; ldata->reload = (override_hdl != INVALID_HANDLE); /* push to load list */ list_addlast(&g_rs.load_list, &ldata->lnode, ldata); return hdl; }
reshandle_t rs_phxprefab_queueload(const char* phx_filepath, reshandle_t override_hdl) { /* if we have an override handle, check in existing queue and see if it's already exists */ if (override_hdl != INVALID_HANDLE && rs_loadqueue_search(override_hdl) != NULL) return override_hdl; reshandle_t hdl = rs_add_resource(phx_filepath, NULL, override_hdl, rs_phxprefab_unload); if (hdl == INVALID_HANDLE) return hdl; struct rs_load_data* ldata = (struct rs_load_data*)mem_pool_alloc(&g_rs.load_data_pool); ASSERT(ldata); memset(ldata, 0x00, sizeof(struct rs_load_data)); str_safecpy(ldata->filepath, sizeof(ldata->filepath), phx_filepath); ldata->hdl = hdl; ldata->type = RS_RESOURCE_PHXPREFAB; ldata->reload = (override_hdl != INVALID_HANDLE); /* push to load list */ list_addlast(&g_rs.load_list, &ldata->lnode, ldata); return hdl; }
void queue_enqueue(QueueSimple *queue, void *ValueToAdd) { queue_alloc_test(queue); list_addlast(queue->list,ValueToAdd); }