fix limit on atoms to ints

This commit is contained in:
Vítor Santos Costa 2013-10-08 13:04:30 +01:00
parent c757e51cb0
commit 70d864b13d
7 changed files with 710 additions and 697 deletions

View File

@ -4151,6 +4151,17 @@ YAP_AtomToInt(Atom At)
SWI_Atoms[AtomTranslations] = At;
Yap_PutAtomTranslation(At, AtomTranslations);
AtomTranslations++;
if (AtomTranslations == MaxAtomTranslations) {
Atom * nt = (Atom *)malloc(sizeof(Atom)*2*MaxAtomTranslations), *ot = SWI_Atoms;
if (nt == NULL) {
Yap_Error(SYSTEM_ERROR,MkAtomTerm(At),"No more room for translations");
return -1;
}
memcpy(nt, ot, sizeof(Atom)*MaxAtomTranslations);
SWI_Atoms = nt;
free( ot );
MaxAtomTranslations *= 2;
}
return AtomTranslations-1;
}

View File

@ -1016,7 +1016,9 @@ InitSWIAtoms(void)
{
extern atom_t ATOM_;
int i=0, j=0;
int j=0;
MaxAtomTranslations = 2*N_SWI_ATOMS ;
SWI_Atoms = (Atom *)malloc(sizeof(Atom)*MaxAtomTranslations);
#include "iswiatoms.h"
Yap_InitSWIHash();
ATOM_ = PL_new_atom("");

View File

@ -295,7 +295,7 @@
struct record_list *yap_records;
Atom swi_atoms[2*N_SWI_ATOMS];
Atom *swi_atoms;
Functor swi_functors[N_SWI_FUNCTORS];
struct swi_reverse_hash swi_reverse_hash[N_SWI_HASH];

View File

@ -300,7 +300,7 @@
MaxAtomTranslations = 2*N_SWI_ATOMS;
InitEmptyWakeups();
MaxEmptyWakeups = 0;

File diff suppressed because it is too large Load Diff

View File

@ -336,14 +336,14 @@ ADDR foreign_code_max ForeignCodeMax =NULL void
struct record_list *yap_records Yap_Records =NULL RestoreYapRecords()
/* SWI atoms and functors */
Atom swi_atoms[2*N_SWI_ATOMS] SWI_Atoms InitSWIAtoms() RestoreSWIAtoms()
Atom *swi_atoms SWI_Atoms InitSWIAtoms() RestoreSWIAtoms()
Functor swi_functors[N_SWI_FUNCTORS] SWI_Functors void void
struct swi_reverse_hash swi_reverse_hash[N_SWI_HASH] SWI_ReverseHash void void
/* integer access to atoms */
Int atom_translations AtomTranslations void void
Int max_atom_translations MaxAtomTranslations =2*N_SWI_ATOMS
Int max_atom_translations MaxAtomTranslations void void
Atom empty_wakeups[MAX_EMPTY_WAKEUPS] EmptyWakeups InitEmptyWakeups() RestoreEmptyWakeups()
int max_empty_wakeups MaxEmptyWakeups =0

View File

@ -47,7 +47,7 @@ gen_defs(Inp,Out) :-
gen_init(Inp,Out) :-
split(Inp," ",["A",_,String]), !,
append([" SWI_Atoms[i++] = Yap_LookupAtom(",String,");"],Out).
append([" YAP_AtomToInt(Yap_LookupAtom(",String,"));"],Out).
gen_init(Inp,Out) :-
split(Inp," ",["F",String,Arity]), !,
append([" SWI_Functors[j++] = Yap_MkFunctor(SWIAtomToAtom(ATOM_",String,"),",Arity,");"],Out).