GNU Emacs has long been using signed types (typically ptrdiff_t) to count objects. This has the advantage that signed integer overflow can be detected automatically on some platforms (unfortunately, size_t arithmetic silently wraps around). I would like to change the Gnulib modules that GNU Emacs uses, to use this style. The main effect on these modules' non-Emacs users would be:

* They accept ptrdiff_t counts, not size_t counts. Normally sizes are computed by new functions like xwgrowalloc. When the caller computes sizes by hand, it is the caller's responsibility to check for integer overflow.

* They report errors via xwalloc_die, not xalloc_die.

I've also changed the modules that GNU grep uses, as a test that this idea works on non-Emacs applications.

As this is a nontrivial change, I'll post the Gnulib patches first without installing them, for discussion.

Reply via email to