[Top][All Lists]

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

Re: [Bug-gnulib] extended xmalloc.c

From: Bruno Haible
Subject: Re: [Bug-gnulib] extended xmalloc.c
Date: Thu, 25 Sep 2003 17:41:37 +0200
User-agent: KMail/1.5

Dave Love wrote:
> Could you include this so that I can sync alloca.c with Emacs.  I
> assume programs other than Emacs might want to block input anyhow, so
> this may be more generally useful.

I doubt this assumption about other programs. The state-of-the-art
technique for doing multiple accesses to possibly non-reentrant code
is to use multiple threads, and with GNU pth we have a portable and
efficient substitute for all systems without native pthreads. Emacs
is, I believe, one of the last programs to use the old technique of
1. doing complex processing in a signal handler (which you aren't allowed
by ANSI C) and 2. block signals around malloc() and free().

> 2003-09-25  Dave Love  <address@hidden>
>       * xmalloc.c [DO_BLOCK_INPUT]: Include blockinput.h.

I think this is the wrong place. If you want to block signals around
all calls of malloc() and free(), the proper place for doing that is
not xmalloc.c - since there are many malloc() calls in other parts of
gnulib (from getopt over regex to strdup). IMO the right place for
this is the config.h file (via acconfig.h or AH_VERBATIM):

  #include <stdlib.h>
  #include "blockinput.h"
  static inline void *interruptsafe_malloc (size_t n) {
    void *result;
    result = malloc (n);
    return result;
  static inline void interruptsafe_free (void *p) {
    free (p);
  #define malloc interruptsafe_malloc
  #define free interruptsafe_free

You don't need to modify the gnulib sources this way.


reply via email to

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