//função insere uma aresta void grafoD_insereAresta(GrafoD gd, char *vID1, char *vID2, char *leftCEP, char *rightCEP, double size, double speed, char* nome){ VerticeV *V1, *aux; Grafo *GD; GD = (Grafo *) gd; aux = calloc(1, sizeof(VerticeV)); aux->id = calloc(strlen(vID1)+2, sizeof(char)); strcpy(aux->id, vID1); V1 = (VerticeV *) get_hashtable(GD->ID, aux); freeVerticeV(aux); ArestaP *atual; if(V1->aresta == NULL){ V1->aresta = calloc(1, sizeof(ArestaP)); atual = V1->aresta; }else{ atual = V1->aresta; while(atual->next != NULL){ atual = atual->next; } atual->next = calloc(1, sizeof(ArestaP)); atual = atual->next; } atual->v1 = V1; aux = calloc(1, sizeof(VerticeV)); aux->id = calloc(strlen(vID2)+2, sizeof(char)); strcpy(aux->id, vID2); atual->v2 = (VerticeV *) get_hashtable(GD->ID, aux); freeVerticeV(aux); atual->disable = 0; atual->nome = calloc(strlen(nome)+2, sizeof(char)); strcpy(atual->nome, nome); atual->cepR = calloc(strlen(rightCEP)+2,sizeof(char)); strcpy(atual->cepR, rightCEP); atual->cepL = calloc(strlen(leftCEP)+2,sizeof(char)); strcpy(atual->cepL, leftCEP); atual->tam = size; atual->speed = speed; atual->next = NULL; insert_hashtable(GD->left, atual); insert_hashtable(GD->right, atual); }
void VM::intern_current_environment(scm_symbol_t symbol, scm_obj_t value) { scm_hashtable_t ht = m_current_environment->variable; scoped_lock lock(ht->lock); scm_obj_t obj = get_hashtable(ht, symbol); if (obj != scm_undef) { assert(GLOCP(obj)); #if USE_PARALLEL_VM if (m_interp->live_thread_count() > 1) { assert(m_heap->in_heap(obj)); m_interp->remember(((scm_gloc_t)obj)->value, value); } #endif m_heap->write_barrier(value); ((scm_gloc_t)obj)->value = value; return; } scm_gloc_t gloc = make_gloc(m_heap, symbol); gloc->value = value; m_heap->write_barrier(symbol); m_heap->write_barrier(gloc); int nsize = put_hashtable(ht, symbol, gloc); if (nsize) rehash_hashtable(m_heap, ht, nsize); }
scm_obj_t VM::lookup_current_environment(scm_symbol_t symbol) { scoped_lock lock(m_current_environment->variable->lock); scm_obj_t obj = get_hashtable(m_current_environment->variable, symbol); if (obj != scm_undef) { assert(GLOCP(obj)); return ((scm_gloc_t)obj)->value; } return scm_undef; }