]> git.cworth.org Git - notmuch/commit
ruby: fix "undefining the allocator of T_DATA" warnings
authorJohannes Larsen <mail@johslarsen.net>
Sun, 1 Sep 2024 00:02:10 +0000 (02:02 +0200)
committerDavid Bremner <david@tethera.net>
Sat, 8 Mar 2025 14:39:22 +0000 (10:39 -0400)
commite8261872dc65ea0259971ff44721a2f7d3f34e67
treecf75d2ef7ab4b95601b73710a680e102e1aa223a
parent53cbb6d0cba6c4763b18f76467e73be21081daae
ruby: fix "undefining the allocator of T_DATA" warnings

Ruby 3.2 introduced a warning when C-extensions use structs without
redefining the allocation default allocation routine meant for objects.
See https://bugs.ruby-lang.org/issues/18007 for details.

In the Ruby bindings this happens at `Data_Wrap_Notmuch_Object` call
sites, so the object types used there needed to update their allocation.

This ruby code (given a database at the hardcoded path with messages
matching `tag:tmp`) exercise all the ruby objects:

    require 'notmuch'
    Notmuch::Database.open File.expand_path("~/mail") do |db|
      db.get_directory("/tmp")
      db.query("tag:tmp").search_threads.each do |t|
        t.messages.each do |m|
          puts m.header("Subject")
        end
      end
    end

Before these changes with ruby 3.2.5 and notmuch 0.38.3 it outputs:

    notmuch.rb:5: warning: undefining the allocator of T_DATA class Notmuch::Query
    notmuch.rb:5: warning: undefining the allocator of T_DATA class Notmuch::Threads
    notmuch.rb:5: warning: undefining the allocator of T_DATA class Notmuch::Thread
    notmuch.rb:6: warning: undefining the allocator of T_DATA class Notmuch::Messages
    notmuch.rb:6: warning: undefining the allocator of T_DATA class Notmuch::Message
    notmuch release 0.38.3 now available

(the last line is the message I tagged with tmp), and after the changes:

    notmuch release 0.38.3 now available
bindings/ruby/init.c