use calloc when malloc allocates memory
add_to_path should store atoms, not strings. git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@558 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
parent
c0d07daec7
commit
0b00f3912b
@ -12,7 +12,7 @@
|
||||
* Last rev: *
|
||||
* mods: *
|
||||
* comments: allocating space *
|
||||
* version:$Id: alloc.c,v 1.20 2002-07-17 20:25:30 vsc Exp $ *
|
||||
* version:$Id: alloc.c,v 1.21 2002-07-23 15:49:06 vsc Exp $ *
|
||||
*************************************************************************/
|
||||
#ifdef SCCS
|
||||
static char SccsId[] = "%W% %G%";
|
||||
@ -860,10 +860,7 @@ InitWorkSpace(Int s)
|
||||
#ifdef M_MMAP_MAX
|
||||
mallopt(M_MMAP_MAX, 0);
|
||||
#endif
|
||||
if (s < MAX_SPACE)
|
||||
ptr = (MALLOC_T)malloc(MAX_SPACE);
|
||||
else
|
||||
ptr = (MALLOC_T)malloc(s);
|
||||
ptr = (MALLOC_T)calloc(MAX_SPACE,1);
|
||||
total_space = s;
|
||||
|
||||
if (ptr == NULL) {
|
||||
|
@ -1061,7 +1061,10 @@ path(Path) :- findall(X,'$in_path'(X),Path).
|
||||
|
||||
add_to_path(New) :- add_to_path(New,last).
|
||||
|
||||
add_to_path(New,Pos) :- '$check_path'(New,Str), '$add_to_path'(Str,Pos).
|
||||
add_to_path(New,Pos) :-
|
||||
'$check_path'(New,Str),
|
||||
atom_codes(Fixed,Str),
|
||||
'$add_to_path'(Str,Pos).
|
||||
|
||||
'$add_to_path'(New,_) :- '$recorded'('$path',New,R), erase(R), fail.
|
||||
'$add_to_path'(New,last) :- !, '$recordz'('$path',New,_).
|
||||
@ -1070,7 +1073,7 @@ add_to_path(New,Pos) :- '$check_path'(New,Str), '$add_to_path'(Str,Pos).
|
||||
remove_from_path(New) :- '$check_path'(New,Path),
|
||||
'$recorded'('$path',Path,R), erase(R).
|
||||
|
||||
'$check_path'(At,SAt) :- atom(At), !, name(At,S), '$check_path'(S,SAt).
|
||||
'$check_path'(At,SAt) :- atom(At), !, atom_codes(At,S), '$check_path'(S,SAt).
|
||||
'$check_path'([],[]).
|
||||
'$check_path'([Ch],[Ch]) :- '$dir_separator'(Ch), !.
|
||||
'$check_path'([Ch],[Ch,A]) :- !, integer(Ch), '$dir_separator'(A).
|
||||
|
Reference in New Issue
Block a user