small bugfixes and leaks, patch by João Silva

This commit is contained in:
Vítor Santos Costa
2014-06-14 10:27:39 +01:00
parent 6286de06be
commit f00a6d5a40
19 changed files with 57 additions and 21 deletions

View File

@@ -1115,7 +1115,7 @@ static Int
p_init_random_state ( USES_REGS1 )
{
register Term t0 = Deref (ARG1);
char *old, * new = (char *) malloc(256);
char *old, *new;
if (IsVarTerm (t0)) {
return(Yap_unify(ARG1,MkIntegerTerm((Int)current_seed)));
@@ -1128,6 +1128,8 @@ p_init_random_state ( USES_REGS1 )
current_seed = (unsigned int) FloatOfTerm (t0);
else
current_seed = (unsigned int) LongIntOfTerm (t0);
new = (char *) malloc(256);
old = initstate(random(), new, 256);
return Yap_unify(ARG2, MkIntegerTerm((Int)old)) &&
Yap_unify(ARG3, MkIntegerTerm((Int)new));