clogger.git  about / heads / tags
configurable request logging for Rack
   commit 4ae4cf792bd794533b8f2ae90f41ff277f97fc9b (patch)
   parent 6b0768f rack 3.x compatibility
     tree c3651594fc6b65ca4bbc2ba90c3db4a739aaf391
   author Eric Wong <bofh@yhbt.net>  2024-01-23 12:57:45 +0000
committer Eric Wong <bofh@yhbt.net>  2024-02-01 07:18:28 +0000

switch to TypedData macros for allocation

This gives us memsize information and appears to fix a leak
under Ruby 3.3.
---
 ext/clogger_ext/clogger.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/ext/clogger_ext/clogger.c b/ext/clogger_ext/clogger.c
index 1993ae8..cea4072 100644
--- a/ext/clogger_ext/clogger.c
+++ b/ext/clogger_ext/clogger.c
@@ -229,18 +229,28 @@ static void clogger_mark(void *ptr)
 	rb_gc_mark(c->body);
 }
 
+static size_t memsize(const void *ptr)
+{
+	return sizeof(struct clogger);
+}
+
+static const rb_data_type_t clogger_type = {
+	"clogger",
+	{ clogger_mark, RUBY_TYPED_DEFAULT_FREE, memsize, /* reserved */ },
+};
+
 static VALUE clogger_alloc(VALUE klass)
 {
 	struct clogger *c;
 
-	return Data_Make_Struct(klass, struct clogger, clogger_mark, -1, c);
+	return TypedData_Make_Struct(klass, struct clogger, &clogger_type, c);
 }
 
 static struct clogger *clogger_get(VALUE self)
 {
 	struct clogger *c;
 
-	Data_Get_Struct(self, struct clogger, c);
+	TypedData_Get_Struct(self, struct clogger, &clogger_type, c);
 	assert(c);
 	return c;
 }


glossary
--------
Commit objects reference one tree, and zero or more parents.

Single parent commits can typically generate a patch in
unified diff format via `git format-patch'.

Multiple parents means the commit is a merge.

Root commits have no ancestor.  Note that it is
possible to have multiple root commits when merging independent histories.

Every commit references one top-level tree object.

git clone http://yhbt.net/clogger.git