From: | Neil Conway <neilc(at)samurai(dot)com> |
---|---|
To: | Russell Smith <mr-russ(at)pws(dot)com(dot)au> |
Cc: | Qingqing Zhou <zhouqq(at)cs(dot)toronto(dot)edu>, pgsql-patches(at)postgresql(dot)org |
Subject: | Re: trivial refactoring of WaitOnLock |
Date: | 2005-03-09 12:05:34 |
Message-ID: | 422EE68E.2030105@samurai.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-patches |
Russell Smith wrote:
> *** 1083,1091 ****
> locallock->lock, locallock->tag.mode);
>
> old_status = pstrdup(get_ps_display());
> ! new_status = (char *) palloc(strlen(old_status) + 10);
> strcpy(new_status, old_status);
> ! strcat(new_status, " waiting");
> set_ps_display(new_status);
>
> awaitedLock = locallock;
> --- 1084,1093 ----
> locallock->lock, locallock->tag.mode);
>
> old_status = pstrdup(get_ps_display());
> ! len = strlen(old_status);
> ! new_status = (char *) palloc(len + 9);
> strcpy(new_status, old_status);
> ! strcpy(&new_status[len], " waiting");
> set_ps_display(new_status);
memcpy(new_status, old_status, len) would be faster yet. Which is what I
originally implemented, and then decided the sprintf() was clearer
(since performance isn't very important here). On reflection, memcpy() +
strcpy() should be fine; I'll commit this tomorrow.
-Neil
From | Date | Subject | |
---|---|---|---|
Next Message | Nicolai Tufar | 2005-03-09 12:40:24 | Re: [pgsql-hackers-win32] snprintf causes regression tests to fail |
Previous Message | Qingqing Zhou | 2005-03-09 09:53:41 | Re: trivial refactoring of WaitOnLock |