[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

memory allocation problem in external predicates

From: Erick Alphonse
Subject: memory allocation problem in external predicates
Date: Sat, 13 Jan 2001 15:29:19 -0500


Allocation memories in my program fail when it is linked with a gprolog
object file.
Please, could you explain me what is the reason and if there is a way to
deal with it?

I'm using a modified version of gprolog 1.2.1 which no longer overrides
malloc,  setting M_MMAP_MAX to 0 (the reason is the newer versions of
gprolog are unstable with my program which crashes at the very top

I use the linux-mandrake 7.2 on an i686 with 256M of RAM and 512M of
swap. the library gmp stands for GNU Multiple Precision Arithmetic
Library. GMP uses malloc, realloc and free for memory allocation. The
void mpz_init_set_ui (mpz_t rop, unsigned long int op) 
initializes the struct rop, which represents an unbounded integer, and
set it to op.

Here we are the code used to examplify my problem:

#include <gmp.h>

void test(void) {
  int i;
  mpz_t b;


:- initialization(top).
:- foreign(test,[return(none)]).

top :-

Runing a.out built with the command
gplc -L '-lgmp' test_alloc_gmp.c -o a.out 
cannot allocate in gmp: Cannot allocate memory

If I link test_alloc_gmp.c with main.c written as follow:

void test(void);

int main() {

the program terminates successfully.

Please, I need help, feel free to ask me any piece of code which will
help for solving this problem.
Erick Alphonse.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]