poke-devel
[Top][All Lists]
Advanced

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

Re: [PATCH] Avoid malloc in pkl_trans1_ps_string


From: Tim Rühsen
Subject: Re: [PATCH] Avoid malloc in pkl_trans1_ps_string
Date: Sat, 4 Apr 2020 20:03:20 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.6.0

Applied your suggestion and pushed.

On 04.04.20 19:54, Jose E. Marchesi wrote:
> 
> Hi Tim!
> 
>     2020-04-04  Tim Rühsen  <address@hidden>
>     
>             * src/pkl-trans.c (pkl_trans1_ps_string): Avoid malloc if string
>             does not need escaping.
>     ---
>      ChangeLog       | 5 +++++
>      src/pkl-trans.c | 5 +++++
>      2 files changed, 10 insertions(+)
>     
>     diff --git a/src/pkl-trans.c b/src/pkl-trans.c
>     index a91d9b3b..5b81a89e 100644
>     --- a/src/pkl-trans.c
>     +++ b/src/pkl-trans.c
>     @@ -269,6 +269,7 @@ PKL_PHASE_BEGIN_HANDLER (pkl_trans1_ps_string)
>        char *new_string_pointer;
>        char *p;
>        size_t string_length, i;
>     +  bool found_slash = false;
>     
> Wouldn't it be more precise to name the variable found_backslash?
> 
>        /* Please keep this code in sync with the string printer in
>           pvm-val.c:pvm_print_val.  */
>     @@ -294,11 +295,15 @@ PKL_PHASE_BEGIN_HANDLER (pkl_trans1_ps_string)
>                    PKL_PASS_ERROR;
>                  }
>                p++;
>     +          found_slash = true;
>              }
>            else
>              string_length++;
>          }
>     
>     +  if (!found_slash)
>     +    goto _exit;
>     +
>        /* Second pass: compose the new string.  */
>        new_string_pointer = xmalloc (string_length + 1);
>     
> Other than that, OK for master.
> Thanks!
> 

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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