static int cmp_atoms(Atom a1, Atom a2) { if (IsWideAtom(a1)) { if (IsWideAtom(a2)) { return wcscmp((wchar_t *)RepAtom(a1)->StrOfAE,(wchar_t *)RepAtom(a2)->StrOfAE); } else { /* The standard does not seem to have nothing on this */ unsigned char *s1 = (unsigned char *)RepAtom(a1)->StrOfAE; wchar_t *s2 = (wchar_t *)RepAtom(a2)->StrOfAE; while (*s1 == *s2) { if (!*s1) return 0; } return *s1-*s2; } } else if (IsWideAtom(a2)) { /* The standard does not seem to have nothing on this */ wchar_t *s1 = (wchar_t *)RepAtom(a1)->StrOfAE; unsigned char *s2 = (unsigned char *)RepAtom(a2)->StrOfAE; while (*s1 == *s2) { if (!*s1) return 0; } return *s1-*s2; } else { return strcmp(RepAtom(a1)->StrOfAE,RepAtom(a2)->StrOfAE); } }
static void clean_atom_list(AtomHashEntry *HashPtr) { Atom atm = HashPtr->Entry; Atom *patm = &(HashPtr->Entry); while (atm != NIL) { AtomEntry *at = RepAtom(atm); if (AtomResetMark(at) || at->PropsOfAE != NIL || (AGCHook != NULL && !AGCHook(atm))) { patm = &(at->NextOfAE); atm = at->NextOfAE; } else { NOfAtoms--; if (IsWideAtom(atm)) { #ifdef DEBUG_RESTORE3 fprintf(stderr, "Purged %p:%S\n", at, at->WStrOfAE); #endif agc_collected += sizeof(AtomEntry)+wcslen(at->WStrOfAE); } else { #ifdef DEBUG_RESTORE3 fprintf(stderr, "Purged %p:%s patm=%p %p\n", at, at->StrOfAE, patm, at->NextOfAE); #endif agc_collected += sizeof(AtomEntry)+strlen(at->StrOfAE); } *patm = atm = at->NextOfAE; Yap_FreeCodeSpace((char *)at); } } }
PL_blob_data(atom_t a, size_t *len, struct PL_blob_t **type) { Atom x = SWIAtomToAtom(a); if (!IsBlob(x)) { if (IsWideAtom(x)) { if ( len ) *len = wcslen(x->WStrOfAE); if ( type ) *type = &unregistered_blob_atom; return x->WStrOfAE; } if ( len ) *len = strlen(x->StrOfAE); if ( type ) *type = &unregistered_blob_atom; return x->StrOfAE; } if ( len ) *len = x->rep.blob[0].length; if ( type ) *type = RepBlobProp(x->PropsOfAE)->blob_t; return x->rep.blob[0].data; }
static void clean_atom_list(AtomHashEntry *HashPtr) { Atom atm = HashPtr->Entry; Atom *patm = &(HashPtr->Entry); while (atm != NIL) { AtomEntry *at = RepAtom(atm); if (AtomResetMark(at) || ( at->PropsOfAE != NIL && !IsBlob(at) ) || (GLOBAL_AGCHook != NULL && !GLOBAL_AGCHook(atm))) { patm = &(at->NextOfAE); atm = at->NextOfAE; } else { NOfAtoms--; if (IsBlob(atm)) { BlobPropEntry *b = RepBlobProp(at->PropsOfAE); if (b->NextOfPE != NIL) { patm = &(at->NextOfAE); atm = at->NextOfAE; continue; } NOfAtoms++; NOfBlobs--; Yap_FreeCodeSpace((char *)b); GLOBAL_agc_collected += sizeof(BlobPropEntry); GLOBAL_agc_collected += sizeof(AtomEntry)+sizeof(size_t)+at->rep.blob->length; } else if (IsWideAtom(atm)) { #ifdef DEBUG_RESTORE3 fprintf(stderr, "Purged %p:%S\n", at, at->WStrOfAE); #endif GLOBAL_agc_collected += sizeof(AtomEntry)+wcslen(at->WStrOfAE); } else { #ifdef DEBUG_RESTORE3 fprintf(stderr, "Purged %p:%s patm=%p %p\n", at, at->StrOfAE, patm, at->NextOfAE); #endif GLOBAL_agc_collected += sizeof(AtomEntry)+strlen(at->StrOfAE); } *patm = atm = at->NextOfAE; Yap_FreeCodeSpace((char *)at); } } }