void collection_push(collection_t* collection, void* item) { collection_node_t* node = _alloc_node(collection); node->item = item; node->next = collection->head; collection->head = node; collection->count++; }
NodeIdx mml_node(MMLObject* mml, const char* name, const char* value) { assert(mml); assert(name); assert(value); // Allocate space for strings, +1 is for null char uint name_len = strlen(name); uint value_len = strlen(value); StrIdx name_idx = _alloc_str(mml, name_len+1); StrIdx value_idx = _alloc_str(mml, value_len+1); // Copy strings strcpy(mml_get_str(mml, name_idx), name); strcpy(mml_get_str(mml, value_idx), value); // Allocate and construct node NodeIdx new_node_idx = _alloc_node(mml); MMLNode* new_node = mml_get_nodeptr(mml, new_node_idx); new_node->name_start = name_idx; new_node->value_start = value_idx; new_node->first_child_idx = new_node->next_idx = 0; return new_node_idx; }