From 61f7d770dbeb5df98b94d9e8cef0c4c86e396447 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Ankarstr=C3=B6m?= Date: Tue, 19 Jul 2022 12:36:08 +0200 Subject: Use Prolog string buffer marks. Speaking of unclear documentation, it is not obvious whether it is necessary for programs calling into Prolog to manually mark and release strings. I suppose that it should be, if the same logic that applies to terms apply to strings. On the other hand, the stack in which the strings are stored belongs to Prolog, and there is nothing that would prevent Prolog from cleaning up the strings when called at a later time. I am not sure. But better safe than sorry, I guess. The Mark class acts like the Frame class. The constructor and destructor are equivalent to the PL_STRINGS_MARK and PL_STRINGS_RELEASE macros. Unlike for 34c3280, I did not notice any differences in memory usage after this change. Perhaps that is because it has no effect; perhaps it is because Prolog's stack is very big. --- c/pl.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'c/pl.h') diff --git a/c/pl.h b/c/pl.h index 4268dad..d4bf18b 100644 --- a/c/pl.h +++ b/c/pl.h @@ -18,6 +18,14 @@ private: fid_t m_f; }; +struct Mark +{ + Mark(); + ~Mark(); +private: + buf_mark_t m_m; +}; + struct Query { Query(module_t ctx, predicate_t p, term_t t0); -- cgit v1.2.3