bool SkAnimateMaker::resolveID(SkDisplayable* displayable, SkDisplayable* original) { SkString newID; bool success = computeID(original, NULL, &newID); if (success) setID(displayable, newID); return success; }
Gdb_ret_t addGraphElement(Graph_t *graph, Gdb_hr_t el_type){ // This will hold the index of the referenced allocation space Gdb_N_t i; // check next available id pthread_mutex_lock(&node_mutex); if(graph->next_available_id < graph->num_vertices){ // We are ok ..allocate here i = graph->next_available_id; graph->next_available_id = graph->next_available_id + 1; // first check to make sure element isnt deleted if(graph->arr_list[i].vertex_status == DELETED){ // this is a deleted vertex - reclaim its space graph->arr_list[i].vertex_status = RECLAIMED; graph->total_deleted = graph->total_deleted - 1; if(&(graph->arr_list[i]) == graph->deleted_element){ // if this is the referenced deleted element then clear the reference // since we are reallocating it. // TODO: Maybe try to find a new deleted if there is one! graph->deleted_element = NULL; } } } else{ // no space left. Check for deleted or set graph->needs_page_increase = true if(graph->total_deleted == 0){ // no deleted elements either set flag for page increase graph->needs_page_increase = true; pthread_mutex_unlock(&node_mutex); return PAGE_FULL; } // ok we have deleted. lets see if we get lucky with the cache if(graph->deleted_element != NULL){ // we got lucky graph->total_deleted = graph->total_deleted - 1; i = graph->deleted_element->list_id; graph->deleted_element = NULL; } else{ // dont search since search space could be huge and take a long time // just flag graph->needs_page_increase = true; pthread_mutex_unlock(&node_mutex); return PAGE_FULL; } } // DO ACTUAL ALLOCATION graph->arr_list[i].vertex_status = ALLOCATED; graph->arr_list[i].type = el_type; // assign it e generic type for indexing // clean memory for number of edges if(graph->arr_list[i].num_edges > 0){ pthread_mutex_lock(&edge_mutex); for(Gdb_N_t j = 0; j < graph->arr_list[i].num_edges; j++){ destroyEdges(graph->arr_list[i].head); } pthread_mutex_unlock(&edge_mutex); } graph->arr_list[i].num_edges = 0; graph->arr_list[i].head = NULL; Gdb_N_t id_hi; Gdb_N_t id_lo; Gdb_ret_t get_ids = computeID(graph, &id_hi, &id_lo, true); if(get_ids == OK){ graph->arr_list[i].id_hi = id_hi; graph->arr_list[i].id_lo = id_lo; } else{ graph->arr_list[i].vertex_status = DELETED; graph->total_deleted = graph->total_deleted + 1; graph->deleted_element = &(graph->arr_list[i]); } pthread_mutex_unlock(&node_mutex); return get_ids; }