misc fixes

git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@1100 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
vsc 2004-07-23 19:02:09 +00:00
parent 16c1c87c50
commit 7c8001d035
2 changed files with 19 additions and 9 deletions

View File

@ -12,7 +12,7 @@
* Last rev: *
* mods: *
* comments: allocating space *
* version:$Id: alloc.c,v 1.52 2004-07-22 21:32:20 vsc Exp $ *
* version:$Id: alloc.c,v 1.53 2004-07-23 19:02:09 vsc Exp $ *
*************************************************************************/
#ifdef SCCS
static char SccsId[] = "%W% %G%";
@ -882,7 +882,10 @@ ExtendWorkSpace(Int s, int fixed_allocation)
}
} else if (a < WorkSpaceTop) {
/* try again */
return ExtendWorkSpace(s, fixed_allocation);
int res = ExtendWorkSpace(s, fixed_allocation);
/* release memory back to system */
munmap(a, s);
return res;
}
WorkSpaceTop = (char *) a + s;
Yap_PrologMode = OldPrologMode;

View File

@ -8,8 +8,11 @@
* *
**************************************************************************
* *
* $Id: sys.c,v 1.19 2004-07-23 03:37:17 vsc Exp $ *
* $Id: sys.c,v 1.20 2004-07-23 19:02:09 vsc Exp $ *
* mods: $Log: not supported by cvs2svn $
* mods: Revision 1.19 2004/07/23 03:37:17 vsc
* mods: fix heap overflow in YAP_LookupAtom
* mods:
* mods: Revision 1.18 2004/01/26 12:51:33 vsc
* mods: should be datime/1 not date/1
* mods:
@ -341,7 +344,7 @@ file_property(void)
static int
p_mktemp(void)
{
#if HAVE_MKTEMP
#if HAVE_MKTEMP || defined(__MINGW32__) || _MSC_VER
char *s, tmp[BUF_SIZE];
s = YAP_AtomName(YAP_AtomOfTerm(YAP_ARG1));
#if HAVE_STRNCPY
@ -351,15 +354,19 @@ p_mktemp(void)
#endif
#if defined(__MINGW32__) || _MSC_VER
if ((s = _mktemp(tmp)) == NULL) {
#else
if ((s = mktemp(tmp)) == NULL) {
#endif
/* return an error number */
return(YAP_Unify(YAP_ARG3, YAP_MkIntTerm(errno)));
}
return(YAP_Unify(YAP_ARG2,YAP_MkAtomTerm(YAP_LookupAtom(s))));
#else
oops
if ((s = mktemp(tmp)) == NULL) {
/* return an error number */
return(YAP_Unify(YAP_ARG3, YAP_MkIntTerm(errno)));
}
return YAP_Unify(YAP_ARG2,YAP_MkAtomTerm(YAP_LookupAtom(s)));
#endif
#else
return FALSE;
#endif
return(TRUE);
}
@ -370,7 +377,7 @@ p_tpmnam(void)
#if HAVE_TMPNAM
return(YAP_Unify(YAP_ARG1,YAP_MkAtomTerm(YAP_LookupAtom(tmpnam(NULL)))));
#else
oops
return FALSE;
#endif
}