notmuch/bindings/ruby
Johannes Larsen e8261872dc 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
2025-03-08 10:39:22 -04:00
..
.gitignore Use rooted paths in .gitignore files 2017-08-18 19:42:35 -03:00
database.c ruby: db: reorganize initializer 2023-05-29 07:51:02 -03:00
defs.h ruby: db: reorganize initializer 2023-05-29 07:51:02 -03:00
directory.c ruby: add filenames helper 2023-04-12 07:05:23 -03:00
extconf.rb ruby: enable garbage collection using talloc 2021-07-18 17:08:53 -03:00
filenames.c ruby: remove FileNames object 2023-04-12 07:30:01 -03:00
init.c ruby: fix "undefining the allocator of T_DATA" warnings 2025-03-08 10:39:22 -04:00
message.c ruby: add filenames helper 2023-04-12 07:05:23 -03:00
messages.c ruby: add tags helper 2023-04-02 19:00:49 -03:00
query.c ruby: query: fix get sort 2023-05-25 07:02:59 -03:00
rdoc.sh ruby: Remove the split file hack from rdoc.sh 2011-07-29 09:44:44 +03:00
README build: integrate building ruby bindings into notmuch build process 2015-06-12 09:12:28 +02:00
status.c Use https instead of http where possible 2016-06-05 08:32:17 -03:00
tags.c ruby: remove Tags object 2023-04-02 19:11:10 -03:00
thread.c ruby: add tags helper 2023-04-02 19:00:49 -03:00
threads.c ruby: new notmuch_rb_object_destroy() helper 2021-05-17 07:25:14 -03:00

To build the the notmuch ruby extension, run the following commands
from the *top level* notmuch source directory:

% ./configure
% make ruby-bindings

The generic documentation about building notmuch also applies.