poke-devel
[Top][All Lists]
Advanced

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

Re: [PATCH 4/4] ios: Remove usage of xalloc from ios.c


From: Jose E. Marchesi
Subject: Re: [PATCH 4/4] ios: Remove usage of xalloc from ios.c
Date: Thu, 14 May 2020 21:08:33 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

Hi Tim.
Thanks for the patch.

     +#define IOS_ENOMEM -5 /* Memory allocation failure.  */
     +

This define should go up in the file, next to IOS_OK and IOS_ERROR.
Thats the place where define error codes used by the several APIs
defined below (and not just by the read/write values API.)

     +              if ((ret = realloc_string(&str, i + 128 * sizeof (char))) < 
0)

Space between function name and (.

    diff --git a/libpoke/pvm.jitter b/libpoke/pvm.jitter
    index 5b00b676..b165ae2d 100644
    --- a/libpoke/pvm.jitter
    +++ b/libpoke/pvm.jitter
    @@ -316,6 +316,8 @@ late-header-c
            {                                                                   
  \
              if (ret == IOS_EIOFF)                                             
  \
                 PVM_RAISE (PVM_E_EOF, PVM_E_EOF_MSG);                          
  \
    +         else if (ret == IOS_ENOMEM)                                       
  \
    +            PVM_RAISE (PVM_E_NOMEM, PVM_E_NOMEM_MSG);                      
  \
              else                                                              
  \
                 PVM_RAISE (PVM_E_IO, PVM_E_IO_MSG);                            
  \
              JITTER_TOP_STACK () = PVM_NULL;                                   
  \
    @@ -4617,6 +4619,8 @@ instruction peeks ()
         {
           if (ret == IOS_EIOFF)
              PVM_RAISE (PVM_E_EOF, PVM_E_EOF_MSG);
    +      else if (ret == IOS_ENOMEM)
    +         PVM_RAISE (PVM_E_NOMEM, PVM_E_NOMEM_MSG);
           else
              PVM_RAISE (PVM_E_IO, PVM_E_IO_MSG);
           JITTER_TOP_STACK () = PVM_NULL;

I don't think we need to add a new exception for this.  Instead, we can
just raise the generic E_io with the "out of memory" in msg, like:

  PVM_RAISE (PVM_E_IO, "out of memory")

This is because it is very unlikely that a Poke program will want to
handle a NOMEM exception.  The hassle of adding a new exception type is
not worth it IMO.




reply via email to

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