update to latest SWI.
This commit is contained in:
parent
163ef9e5d0
commit
8d404a41cf
@ -19,18 +19,18 @@
|
|||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public
|
You should have received a copy of the GNU Lesser General Public
|
||||||
License along with this library; if not, write to the Free Software
|
License along with this library; if not, write to the Free Software
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "pl-incl.h"
|
#include "pl-incl.h"
|
||||||
|
|
||||||
void
|
int
|
||||||
growBuffer(Buffer b, size_t minfree)
|
growBuffer(Buffer b, size_t minfree)
|
||||||
{ size_t osz = b->max - b->base, sz = osz;
|
{ size_t osz = b->max - b->base, sz = osz;
|
||||||
size_t top = b->top - b->base;
|
size_t top = b->top - b->base;
|
||||||
|
|
||||||
if ( b->max - b->top >= (int)minfree )
|
if ( b->max - b->top >= (int)minfree )
|
||||||
return;
|
return TRUE;
|
||||||
|
|
||||||
if ( sz < 512 )
|
if ( sz < 512 )
|
||||||
sz = 512; /* minimum reasonable size */
|
sz = 512; /* minimum reasonable size */
|
||||||
@ -40,12 +40,12 @@ growBuffer(Buffer b, size_t minfree)
|
|||||||
if ( b->base != b->static_buffer )
|
if ( b->base != b->static_buffer )
|
||||||
{ b->base = realloc(b->base, sz);
|
{ b->base = realloc(b->base, sz);
|
||||||
if ( !b->base )
|
if ( !b->base )
|
||||||
outOfCore();
|
return FALSE;
|
||||||
} else /* from static buffer */
|
} else /* from static buffer */
|
||||||
{ char *new;
|
{ char *new;
|
||||||
|
|
||||||
if ( !(new = malloc(sz)) )
|
if ( !(new = malloc(sz)) )
|
||||||
outOfCore();
|
return FALSE;
|
||||||
|
|
||||||
memcpy(new, b->static_buffer, osz);
|
memcpy(new, b->static_buffer, osz);
|
||||||
b->base = new;
|
b->base = new;
|
||||||
@ -53,6 +53,8 @@ growBuffer(Buffer b, size_t minfree)
|
|||||||
|
|
||||||
b->top = b->base + top;
|
b->top = b->base + top;
|
||||||
b->max = b->base + sz;
|
b->max = b->base + sz;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public
|
You should have received a copy of the GNU Lesser General Public
|
||||||
License along with this library; if not, write to the Free Software
|
License along with this library; if not, write to the Free Software
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef BUFFER_H_INCLUDED
|
#ifndef BUFFER_H_INCLUDED
|
||||||
@ -39,14 +39,16 @@ typedef struct
|
|||||||
char * top; /* pointer to top */
|
char * top; /* pointer to top */
|
||||||
char * max; /* current location */
|
char * max; /* current location */
|
||||||
char static_buffer[sizeof(char *)];
|
char static_buffer[sizeof(char *)];
|
||||||
} buffer, *Buffer;
|
} MAY_ALIAS buffer, *Buffer;
|
||||||
|
|
||||||
void growBuffer(Buffer b, size_t minfree);
|
int growBuffer(Buffer b, size_t minfree);
|
||||||
|
|
||||||
#define addBuffer(b, obj, type) \
|
#define addBuffer(b, obj, type) \
|
||||||
do \
|
do \
|
||||||
{ if ( (b)->top + sizeof(type) > (b)->max ) \
|
{ if ( (b)->top + sizeof(type) > (b)->max ) \
|
||||||
growBuffer((Buffer)b, sizeof(type)); \
|
{ if ( !growBuffer((Buffer)b, sizeof(type)) ) \
|
||||||
|
outOfCore(); \
|
||||||
|
} \
|
||||||
*((type *)(b)->top) = obj; \
|
*((type *)(b)->top) = obj; \
|
||||||
(b)->top += sizeof(type); \
|
(b)->top += sizeof(type); \
|
||||||
} while(0)
|
} while(0)
|
||||||
@ -57,7 +59,9 @@ void growBuffer(Buffer b, size_t minfree);
|
|||||||
size_t _len = _tms * sizeof(type); \
|
size_t _len = _tms * sizeof(type); \
|
||||||
type *_d, *_s = (type *)ptr; \
|
type *_d, *_s = (type *)ptr; \
|
||||||
if ( (b)->top + _len > (b)->max ) \
|
if ( (b)->top + _len > (b)->max ) \
|
||||||
growBuffer((Buffer)b, _len); \
|
{ if ( !growBuffer((Buffer)b, _len) ) \
|
||||||
|
outOfCore(); \
|
||||||
|
} \
|
||||||
_d = (type *)(b)->top; \
|
_d = (type *)(b)->top; \
|
||||||
while ( _tms-- ) \
|
while ( _tms-- ) \
|
||||||
*_d++ = *_s++; \
|
*_d++ = *_s++; \
|
||||||
|
Reference in New Issue
Block a user