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("");