MPI fixes
This commit is contained in:
@@ -98,11 +98,23 @@ expand_buffer(const size_t space ) {
|
||||
/*
|
||||
* Changes the size of the buffer to contain at least newsize bytes
|
||||
*/
|
||||
void
|
||||
change_buffer_size(const size_t newsize) {
|
||||
if ( BUFFER_SIZE>=BLOCK_SIZE && BUFFER_SIZE>=newsize)
|
||||
return;
|
||||
if (realloc( BUFFER_PTR, newsize) == NULL) {
|
||||
void change_buffer_size(const size_t newsize) {
|
||||
if ( BUFFER_PTR == NULL )
|
||||
{
|
||||
if ((BUFFER_PTR = malloc( BLOCK_SIZE < newsize ? newsize : BLOCK_SIZE)) == NULL) {
|
||||
YAP_Error(0,0,"Prolog2Term: Out of memory.\n");
|
||||
#ifdef MPI
|
||||
MPI_Finalize();
|
||||
#endif
|
||||
YAP_Exit( 1 );
|
||||
}
|
||||
}
|
||||
else if ((BUFFER_SIZE>=BLOCK_SIZE &&
|
||||
BUFFER_SIZE>=newsize) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
else if ((BUFFER_PTR = realloc( BUFFER_PTR, newsize)) == NULL) {
|
||||
YAP_Error(0,0,"Prolog2Term: Out of memory.\n");
|
||||
#ifdef MPI
|
||||
MPI_Finalize();
|
||||
@@ -137,7 +149,7 @@ p2c_putt(const YAP_Term t) {
|
||||
size_t
|
||||
write_term_to_stream(const int fd,const YAP_Term term) {
|
||||
|
||||
RESET_BUFFER;
|
||||
RESET_BUFFER();
|
||||
printf("BUFFER_PTR=%p\n", BUFFER_PTR);
|
||||
p2c_putt(term);
|
||||
if (write(fd,(void*)BUFFER_PTR,BUFFER_LEN) < 0) { // write term
|
||||
@@ -154,7 +166,7 @@ YAP_Term
|
||||
read_term_from_stream(const int fd) {
|
||||
size_t size;
|
||||
|
||||
RESET_BUFFER;
|
||||
RESET_BUFFER();
|
||||
if (!read(fd,(void*)&size,sizeof(size_t))) { // read the size of the term
|
||||
YAP_Error(0,0,"Prolog2Term: IO error in read.\n");
|
||||
}
|
||||
@@ -179,7 +191,7 @@ read_term_from_stream(const int fd) {
|
||||
char*
|
||||
term2string(char *const ptr, size_t *size, const YAP_Term t) {
|
||||
char *ret;
|
||||
RESET_BUFFER;
|
||||
RESET_BUFFER();
|
||||
|
||||
do {
|
||||
if (*size == 0) {
|
||||
|
Reference in New Issue
Block a user