On 09/03/16(Wed) 10:06, Otto Moerbeek wrote:
> a future goal for malloc is to use multiple pools in threaded environments,
> to reduce lock contention. 
> 
> This is a small first step towards that goal: move two globals to the
> pool-specific struct dir_info. Currently there's only a single pool,
> but that will change one day.
> 
> Lightly tested by myself on amd64, you can help by reviewing and
> testing this.

Looks good, I have one question, see below.

> Index: malloc.c
> ===================================================================
> RCS file: /cvs/src/lib/libc/stdlib/malloc.c,v
> retrieving revision 1.182
> diff -u -p -r1.182 malloc.c
> --- malloc.c  25 Feb 2016 00:38:51 -0000      1.182
> +++ malloc.c  9 Mar 2016 08:31:52 -0000
> @@ -243,7 +243,7 @@ hash(void *p)
>  }
>  
>  static void
> -wrterror(char *msg, void *p)
> +wrterror(struct dir_info *d, char *msg, void *p)
>  {
>       char            *q = " error: ";
>       struct iovec    iov[7];
> @@ -256,8 +256,13 @@ wrterror(char *msg, void *p)
>       iov[1].iov_base = pidbuf;
>       snprintf(pidbuf, sizeof(pidbuf), "(%d) in ", getpid());
>       iov[1].iov_len = strlen(pidbuf);
> -     iov[2].iov_base = malloc_func;
> -     iov[2].iov_len = strlen(malloc_func);
> +     if (d != NULL) {
> +             iov[2].iov_base = d->func;
> +             iov[2].iov_len = strlen(d->func);
> +     } else {
> +             iov[2].iov_base = "unknown";
> +             iov[2].iov_len = 7;
> +     }

When can ``d'' be NULL?  Isn't this a programming error?

Reply via email to