emacs-diffs
[Top][All Lists]
Advanced

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

scratch/igc 18244fa8f26: Ensure JSON parser allocations are traced (bug#


From: Pip Cet
Subject: scratch/igc 18244fa8f26: Ensure JSON parser allocations are traced (bug#74547)
Date: Sun, 1 Dec 2024 10:56:20 -0500 (EST)

branch: scratch/igc
commit 18244fa8f26c5f7585e83ac5eda4f562d2639aef
Author: Pip Cet <pipcet@protonmail.com>
Commit: Pip Cet <pipcet@protonmail.com>

    Ensure JSON parser allocations are traced (bug#74547)
    
    * src/json.c (json_parser_done):
    (json_make_object_workspace_for_slow_path): Use IGC-aware allocations.
---
 src/json.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/src/json.c b/src/json.c
index eb446f5c221..900fbcbb41a 100644
--- a/src/json.c
+++ b/src/json.c
@@ -807,7 +807,11 @@ json_parser_done (void *parser)
 {
   struct json_parser *p = (struct json_parser *) parser;
   if (p->object_workspace != p->internal_object_workspace)
+#ifdef HAVE_MPS
+    igc_xfree (p->object_workspace);
+#else
     xfree (p->object_workspace);
+#endif
   if (p->byte_workspace != p->internal_byte_workspace)
     xfree (p->byte_workspace);
 }
@@ -833,17 +837,31 @@ json_make_object_workspace_for_slow_path (struct 
json_parser *parser,
   if (parser->object_workspace_size
       == JSON_PARSER_INTERNAL_OBJECT_WORKSPACE_SIZE)
     {
+#ifndef HAVE_MPS
       new_workspace_ptr
        = xnmalloc (new_workspace_size, sizeof (Lisp_Object));
+#else
+      new_workspace_ptr
+       = igc_xalloc_lisp_objs_exact (new_workspace_size);
+#endif
       memcpy (new_workspace_ptr, parser->object_workspace,
              (sizeof (Lisp_Object)
               * parser->object_workspace_current));
     }
   else
     {
+#ifndef HAVE_MPS
       new_workspace_ptr
        = xnrealloc (parser->object_workspace, new_workspace_size,
                     sizeof (Lisp_Object));
+#else
+      new_workspace_ptr
+       = igc_xalloc_lisp_objs_exact (new_workspace_size);
+      memcpy (new_workspace_ptr, parser->object_workspace,
+             (sizeof (Lisp_Object)
+              * parser->object_workspace_current));
+      igc_xfree (parser->object_workspace);
+#endif
     }
 
   parser->object_workspace = new_workspace_ptr;



reply via email to

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