int destroySourceFile(SourceFile sf) { DEBUG(MSG_SRCFILE, Sdprintf("Destroying source file %s\n", PL_atom_chars(sf->name))); clearSourceAdmin(sf); LOCK(); if ( sf->magic == SF_MAGIC ) { SourceFile f; sf->magic = SF_MAGIC_DESTROYING; f = deleteHTable(GD->files.table, (void*)sf->name); assert(f); PL_unregister_atom(sf->name); putSourceFileArray(sf->index, NULL); if ( GD->files.no_hole_before > sf->index ) GD->files.no_hole_before = sf->index; } UNLOCK(); unallocSourceFile(sf); return TRUE; }
int destroySourceFile(SourceFile sf) { Symbol s; DEBUG(MSG_SRCFILE, Sdprintf("Destroying source file %s\n", PL_atom_chars(sf->name))); clearSourceAdmin(sf); LOCK(); s = lookupHTable(GD->files.table, (void*)sf->name); assert(s); deleteSymbolHTable(GD->files.table, s); PL_unregister_atom(sf->name); putSourceFileArray(sf->index, NULL); if ( GD->files.no_hole_before > sf->index ) GD->files.no_hole_before = sf->index; UNLOCK(); unallocSourceFile(sf); return TRUE; }
static void registerSourceFile(SourceFile sf) /* locked by lookupSourceFile() */ { size_t index; int i; int last = FALSE; if ( GD->files.no_hole_before == 0 ) GD->files.no_hole_before = 1; for(index=GD->files.no_hole_before, i=MSB(index); !last; i++) { size_t upto = (size_t)2<<i; SourceFile *b = GD->files.array.blocks[i]; if ( upto >= GD->files.highest ) { upto = GD->files.highest; last = TRUE; } for(; index<upto; index++) { if ( b[index] == NULL ) { sf->index = index; b[index] = sf; GD->files.no_hole_before = index+1; return; } } } GD->files.no_hole_before = index+1; sf->index = index; if ( (size_t)sf->index != index ) fatalError("Too many (%d) source files", index); putSourceFileArray(index, sf); GD->files.highest = index+1; }