[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Bug-gnulib] xalloc patch to check for address arithmetic overflow
From: |
Bruno Haible |
Subject: |
Re: [Bug-gnulib] xalloc patch to check for address arithmetic overflow |
Date: |
Thu, 16 Oct 2003 15:30:29 +0200 |
User-agent: |
KMail/1.5 |
Paul Eggert wrote:
> +inline void *
> +xnmalloc (size_t n, size_t s)
> +inline void *
> +xnrealloc (void *p, size_t n, size_t s)
'inline' without static is likely to give problems; the GCC manual says
"For future compatibility with when GCC implements ISO C99 semantics
for inline functions, it is best to use `static inline' only. (The
existing semantics will remain available when `-std=gnu89' is
specified, but eventually the default will be `-std=gnu99' and that
will implement the C99 semantics, though it does not do so yet.)"
I'd use 'static inline' helper functions instead, or put a simplified
copy of the body of xnmalloc (without the array_size_overflow check) into
xmalloc.
Also the file should #include <string.h> since it uses memset and memcpy.
Bruno