Re: [hackers] [PATCH 1/6] ed: Add optional parameter to string()

From: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
Date: Thu, 28 Dec 2023 10:33:54 +0100

Hi,

On Tue, Dec 26, 2023 at 03:40:36PM +0100, Страхиња Радић wrote:
> On 23/12/24 11:46AM, Rene Kita wrote:
> > > + if (!from) {
> > > + len = 0;
> > > + t = NULL;
> > > + } else {
>
> This seems redundant. Normally, NULL shouldn't be passed, and even if it is, it
> is the responsibility of the "user-programmer" (think libc functions). This is
> further backed by the standard pattern of always checking for failed malloc.

As Rene commented maybe is better to split this function in two different
functions. Assigning NULL in this case was needed because it was used later
in a call to realloc. Ed is different to other sbase programs where is acceptable
to abort when we run out of memory, because it is mainly used in an interactive
way and discarding all the changes from the user in that case seems a bit weird.

Regards,
Received on Thu Dec 28 2023 - 10:33:54 CET

This archive was generated by hypermail 2.3.0 : Thu Dec 28 2023 - 10:36:33 CET