Esempio n. 1
0
void cartSim(char *host, char *user, char *password, char *database)
/* cartSim - Simulate cart usage by genome browser users. */
{
char *create = optionVal("create", NULL);
char *clone = optionVal("clone", NULL);
char *cleanup = optionVal("cleanup", NULL);
if (create != NULL)
    {
    checkNotRealDatabase(host, user, password, database);
    checkEmptyOrFakeDatabase(host, user, password, database);
    createNewFakeDatabase(host, user, password, database);
    createFakeEntries(host, user, password, database, sqlUnsigned(create));
    }
else if (clone != NULL)
    {
    checkNotRealDatabase(host, user, password, database);
    checkEmptyOrFakeDatabase(host, user, password, database);
    createNewFakeDatabase(host, user, password, database);
    cloneOldDatabase(host, user, password, database, clone);
    }
else if (cleanup != NULL)
    {
    cleanupTable(host, user, password, database, userTable, sqlUnsigned(cleanup));
    }
else
    {
    cartSimulate(host, user, password, database);
    }
}
Esempio n. 2
0
void cleanupEnvironment(Environment *env) {
  if (env) {
    while (env) {
      if (env->bindings->type == tableType) {
	cleanupTable(env->bindings->tableValue);
	free(env->bindings);
      }
      env = env->parent;
    }
  }
  free(env);
}
Esempio n. 3
0
/*
  Auto doubling the hash table if the size of the hash table reaches 2/3 of the capacity, 
  where 2/3 is the load factor.
*/
int autoDouble(HashTable* table){
  //assert(1==2);
  if (table){
    int oldCapacity = table->capacity;
    int i;
    HashTable* newTable = initializeTable(table->capacity*2);
    for (i=0;i<oldCapacity;i++){
      if ((table->entries)[i].car){
	if (((table->entries)[i].car)->type == symbolType){
	  insertItem(newTable, ((table->entries)[i].car)->symbolValue, (table->entries)[i].cdr);
	}	
      }
    }
    cleanupTable(table);
    table->entries = newTable->entries;
    free(newTable);
    return 1;
  }else{
    return 0;
  }
}
Esempio n. 4
0
/* 
   Destroy the table by freeing the cons cells, keys and hash table itself.
   This function cannot free any payloads.
*/
void destroyTable(HashTable *table){
  if (table){
    cleanupTable(table);
    free(table);
  }
}