emacs-diffs
[Top][All Lists]
Advanced

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

scratch/igc 38a49e97475 2/3: Add function to init an MPS header for stri


From: Pip Cet
Subject: scratch/igc 38a49e97475 2/3: Add function to init an MPS header for string data
Date: Sat, 20 Jul 2024 13:43:58 -0400 (EDT)

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

    Add function to init an MPS header for string data
    
    * src/igc.c (gc_init_header_bytes): New function.
---
 src/igc.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/src/igc.c b/src/igc.c
index 8708929a1f6..7cdd665770a 100644
--- a/src/igc.c
+++ b/src/igc.c
@@ -635,6 +635,7 @@ set_header (struct igc_header *h, enum igc_obj_type type,
 }
 
 static unsigned alloc_hash (void);
+static size_t igc_round (size_t nbytes, size_t align);
 
 /* Called throughout Emacs to initialize the GC header of an object
    which does not live in GC-managed memory, such as pure objects and
@@ -672,6 +673,21 @@ void gc_init_header (union gc_header *header, enum 
igc_obj_type type)
     }
 }
 
+void gc_init_header_bytes (union gc_header *header, enum igc_obj_type type,
+                          size_t nbytes)
+{
+  struct igc_header *h = (struct igc_header *)header;
+  switch (type)
+    {
+    case IGC_OBJ_STRING_DATA:
+      set_header (h, IGC_OBJ_STRING_DATA, sizeof (struct Lisp_String_Data) +
+                 igc_round (nbytes, IGC_ALIGN), alloc_hash());
+      break;
+    default:
+      emacs_abort ();
+    }
+}
+
 /* Given a pointer to the client area of an object, CLIENT, return
    the base address of the object in MPS. */
 



reply via email to

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