lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <efd0f1d3-4442-0559-73f1-20185e0ba33d@gnuweeb.org>
Date:   Sun, 20 Mar 2022 23:10:14 +0700
From:   Ammar Faizi <ammarfaizi2@...weeb.org>
To:     Alviro Iskandar Setiawan <alviro.iskandar@...weeb.org>
Cc:     Willy Tarreau <w@....eu>, "Paul E. McKenney" <paulmck@...nel.org>,
        Nugraha <richiisei@...il.com>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
        GNU/Weeb Mailing List <gwml@...r.gnuweeb.org>
Subject: Re: [RFC PATCH v1 5/6] tools/nolibc/stdlib: Implement `malloc()`,
 `calloc()`, `realloc()` and `free()`

On 3/20/22 10:50 PM, Alviro Iskandar Setiawan wrote:
> This better be simplified like this, so only have 1 malloc() call that
> applies to both branches.
> 
>    void *realloc(void *old_ptr, size_t new_size)
>    {
>           struct nolibc_heap *heap;
>           void *ret;
> 
>           ret = malloc(new_size);
>           if (__builtin_expect(!ret, 0))
>                   return NULL;
> 
>           if (!old_ptr)
>                   return ret;
> 
>           heap = container_of(old_ptr, struct nolibc_heap, user_p);
>           memcpy(ret, heap->user_p, heap->len);
>           munmap(heap, heap->len);
>           return ret;
>    }

That looks better, will take this for the v2. Thanks!

-- 
Ammar Faizi

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ