poke-devel
[Top][All Lists]
Advanced

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

Re: [PATCH 2/6] libpoke: Use strndup instead of xstrndup


From: Jose E. Marchesi
Subject: Re: [PATCH 2/6] libpoke: Use strndup instead of xstrndup
Date: Thu, 07 May 2020 18:43:44 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

Hi Tim.
This is OK.

    2020-05-06  Tim Rühsen  <address@hidden>
    
            * bootstrap.conf: Remove xstrndup from libpoke_modules.
            * libpoke/pkl-trans.c (pkl_trans1_ps_print_stmt):  Use strndup
            instead of xstrndup.
    ---
     ChangeLog           | 6 ++++++
     bootstrap.conf      | 1 -
     libpoke/pkl-trans.c | 9 ++++++---
     3 files changed, 12 insertions(+), 4 deletions(-)
    
    diff --git a/bootstrap.conf b/bootstrap.conf
    index 3cf1b953..6e58d788 100644
    --- a/bootstrap.conf
    +++ b/bootstrap.conf
    @@ -81,7 +81,6 @@ libpoke_modules="
       tempname
       tmpdir
       xalloc
    -  xstrndup
       "
    
     # TODO: Remove this after the 1.0 release. Until then, this helps 
developers
    diff --git a/libpoke/pkl-trans.c b/libpoke/pkl-trans.c
    index a8fba37e..593e99ef 100644
    --- a/libpoke/pkl-trans.c
    +++ b/libpoke/pkl-trans.c
    @@ -24,7 +24,6 @@
     #include <string.h>
     #include <xalloc.h>
     #include <stdlib.h>
    -#include "xstrndup.h"
    
     #include "pk-utils.h"
    
    @@ -572,7 +571,9 @@ PKL_PHASE_BEGIN_HANDLER (pkl_trans1_ps_print_stmt)
       if (*p != '%')
         {
           p = strchrnul (fmt, '%');
    -      PKL_AST_PRINT_STMT_PREFIX (print_stmt) = xstrndup (fmt, p - fmt);
    +      PKL_AST_PRINT_STMT_PREFIX (print_stmt) = strndup (fmt, p - fmt);
    +      if (!PKL_AST_PRINT_STMT_PREFIX (print_stmt))
    +        PKL_ICE (PKL_AST_LOC (print_stmt), _("out of memory"));
         }
    
       /* Process the format string.  */
    @@ -841,7 +842,9 @@ PKL_PHASE_BEGIN_HANDLER (pkl_trans1_ps_print_stmt)
           if (*p != '\0' && *p != '%')
             {
               char *end = strchrnul (p, '%');
    -          PKL_AST_PRINT_STMT_ARG_SUFFIX (arg) = xstrndup (p, end - p);
    +          PKL_AST_PRINT_STMT_ARG_SUFFIX (arg) = strndup (p, end - p);
    +          if (!PKL_AST_PRINT_STMT_ARG_SUFFIX (arg))
    +            PKL_ICE (PKL_AST_LOC (print_stmt), _("out of memory"));
               p = end;
             }
         }
    --
    2.26.2



reply via email to

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