poke-devel
[Top][All Lists]
Advanced

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

Re: [PATCH] Remove include xalloc.h from libpoke/pkl.c


From: Tim Rühsen
Subject: Re: [PATCH] Remove include xalloc.h from libpoke/pkl.c
Date: Sat, 16 May 2020 13:28:57 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.8.0

Pushed.

On 15.05.20 20:48, Jose E. Marchesi wrote:
> 
> Hi Tim.
> 
> OK for master.
> Thanks!
> 
> 
>     2020-05-15  Tim Rühsen  <address@hidden>
>     
>             * libpoke/pkl.c: Remove include xalloc.h.
>             (pkl_new): Use calloc instead of xzalloc.
>             (pkl_new): Free memory when returning NULL.
> 
> 
>      ChangeLog     |  8 +++++++-
>      libpoke/pkl.c | 19 ++++++++++++++++---
>      2 files changed, 23 insertions(+), 4 deletions(-)
>     
>     diff --git a/libpoke/pkl.c b/libpoke/pkl.c
>     index 8a369235..46336f79 100644
>     --- a/libpoke/pkl.c
>     +++ b/libpoke/pkl.c
>     @@ -24,7 +24,6 @@
>      #include <stdio.h> /* For fopen, etc */
>      #include <stdlib.h>
>      #include <string.h>
>     -#include <xalloc.h>
>     
>      #include "dirname.h"
>     
>     @@ -67,7 +66,10 @@ pkl_compiler
>      pkl_new (pvm vm, const char *rt_path)
>      {
>        pkl_compiler compiler
>     -    = xzalloc (sizeof (struct pkl_compiler));
>     +    = calloc (1, sizeof (struct pkl_compiler));
>     +
>     +  if (!compiler)
>     +    goto out_of_memory;
>     
>        /* Create the top-level compile-time environment.  This will be used
>           for as long as the incremental compiler lives.  */
>     @@ -93,11 +95,14 @@ pkl_new (pvm vm, const char *rt_path)
>     
>          if (!pkl_execute_file (compiler, poke_rt_pk))
>            {
>     +        free (poke_rt_pk);
>     +
>              pk_term_class ("error");
>              pk_puts ("internal error: ");
>              pk_term_end_class ("error");
>              pk_puts ("compiler failed to bootstrap itself\n");
>     
>     +        pkl_free (compiler);
>              return NULL;
>            }
>          free (poke_rt_pk);
>     @@ -112,13 +117,21 @@ pkl_new (pvm vm, const char *rt_path)
>            goto out_of_memory;
>     
>          if (!pkl_execute_file (compiler, poke_std_pk))
>     -      return NULL;
>     +      {
>     +        free (poke_std_pk);
>     +        pkl_free (compiler);
>     +        return NULL;
>     +      }
>     +
>          free (poke_std_pk);
>        }
>     
>        return compiler;
>     
>      out_of_memory:
>     +  if (compiler)
>     +    pkl_free (compiler);
>     +
>        pk_term_class ("error");
>        pk_puts ("error: ");
>        pk_term_end_class ("error");
>     --
>     2.26.2
> 

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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