Fix WriteBuffer and add WriteDynamicBuffer
This commit is contained in:
@@ -479,6 +479,7 @@ X_API Term STD_PROTO(YAP_Read, (IOSTREAM *));
|
||||
X_API void STD_PROTO(YAP_Write, (Term, IOSTREAM *, int));
|
||||
X_API Term STD_PROTO(YAP_CopyTerm, (Term));
|
||||
X_API int STD_PROTO(YAP_WriteBuffer, (Term, char *, size_t, int));
|
||||
X_API char *STD_PROTO(YAP_WriteDynamicBuffer, (Term, char *, size_t, size_t *, int *, int));
|
||||
X_API char *STD_PROTO(YAP_CompileClause, (Term));
|
||||
X_API void STD_PROTO(YAP_PutValue, (Atom,Term));
|
||||
X_API Term STD_PROTO(YAP_GetValue, (Atom));
|
||||
@@ -2802,10 +2803,30 @@ YAP_CopyTerm(Term t)
|
||||
X_API int
|
||||
YAP_WriteBuffer(Term t, char *buf, size_t sze, int flags)
|
||||
{
|
||||
int enc;
|
||||
size_t length;
|
||||
char *b;
|
||||
|
||||
BACKUP_MACHINE_REGS();
|
||||
t = Yap_TermToString(t, buf, sze, flags);
|
||||
if ((b = Yap_TermToString(t, buf, sze, &length, &enc, flags)) != buf) {
|
||||
if (b) free(b);
|
||||
RECOVER_MACHINE_REGS();
|
||||
return FALSE;
|
||||
}
|
||||
RECOVER_MACHINE_REGS();
|
||||
return t;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
X_API char *
|
||||
YAP_WriteDynamicBuffer(Term t, char *buf, size_t sze, size_t *lengthp, int *encp, int flags)
|
||||
{
|
||||
int enc;
|
||||
char *b;
|
||||
|
||||
BACKUP_MACHINE_REGS();
|
||||
b = Yap_TermToString(t, buf, sze, lengthp, encp, flags);
|
||||
RECOVER_MACHINE_REGS();
|
||||
return b;
|
||||
}
|
||||
|
||||
X_API char *
|
||||
|
Reference in New Issue
Block a user