NULL need not be all bits 0

D. Hugh Redelmeier hugh@mimosa.com
Mon, 25 Oct 1999 16:28:48 -0400 (EDT)



| From: Werner Koch <wk@gnupg.org>

| > gnupg-1.0.0/mpi/mpi-mpow.c" line 90:
| > G = m_alloc_clear( (1<<k) * sizeof *G );
|
| But sure, you are right here - in this case the compiler can't know
| that we are going to store 0s in some pointers.
That is the case I was talking about. I have used such a machine (but they are rare). I've found the problem in three spots in primegen.c too. I've replaced it with calls to the following macro. The advantage of a macro is that it can be generic. #define m_alloc_ptrs_clear(pp, n) { \ int c = (n); \ (pp) = alloc_bytes((n) * sizeof(*(pp)), "m_alloc_ptrs_clear"); \ while (c > 0) (pp)[--c] = NULL; \ } Hugh Redelmeier hugh@mimosa.com voice: +1 416 482-8253