My new distro "Glacies" - GNU/Linux
Users browsing this thread: 5 Guest(s)
|
|||
(15-01-2020, 04:31 PM)eadwardus Wrote: calling realloc with just the required space is not optimal I think I express poorly. So I will express myself in term of other people's code. :) Here is the mechanism I am talking about in DJB code (skalibs): Code: int stralloc_ready_tuned (stralloc *sa, size_t n, size_t base, size_t a, size_t b) https://github.com/skarnet/skalibs/blob/...lloc.h#L21 https://github.com/skarnet/skalibs/blob/...tb.c#L6-L8 Here is how it is already done in a few libcs. Musl: Code: static int adjust_size(size_t *n) OpenBSD: Code: #define PAGEROUND(x) (((x) + (MALLOC_PAGEMASK)) & ~MALLOC_PAGEMASK) Glibc: Code: /* pad request bytes into a usable size -- internal version */ But then, there still might be something I missed about that, which makes stralloc's (->a) size_t still useful. This happen often to me. I read some other code, and then I get what I read a day ago was there... In any way, there is not much benefit besides a single function removed (in case of skarnet's code), and no performance benefit! Just me choosing the color of the bicycle shedding... |
|||
Messages In This Thread |
My new distro "Glacies" - by eadwardus - 08-12-2019, 03:55 PM
RE: My new distro "Glacies" - by bouncepaw - 09-12-2019, 01:54 PM
RE: My new distro "Glacies" - by z3bra - 09-12-2019, 08:08 PM
RE: My new distro "Glacies" - by eadwardus - 09-12-2019, 11:59 PM
RE: My new distro "Glacies" - by z3bra - 10-12-2019, 04:25 AM
RE: My new distro "Glacies" - by eadwardus - 10-12-2019, 11:52 AM
RE: My new distro "Glacies" - by jkl - 10-12-2019, 07:40 PM
RE: My new distro "Glacies" - by josuah - 10-12-2019, 08:48 PM
RE: My new distro "Glacies" - by josuah - 10-12-2019, 08:50 PM
RE: My new distro "Glacies" - by josuah - 10-12-2019, 08:52 PM
RE: My new distro "Glacies" - by eadwardus - 11-12-2019, 03:28 AM
RE: My new distro "Glacies" - by eadwardus - 31-12-2019, 11:52 PM
RE: My new distro "Glacies" - by josuah - 13-01-2020, 08:42 PM
RE: My new distro "Glacies" - by josuah - 13-01-2020, 09:12 PM
RE: My new distro "Glacies" - by eadwardus - 15-01-2020, 04:31 PM
RE: My new distro "Glacies" - by josuah - 18-01-2020, 12:12 PM
RE: My new distro "Glacies" - by josuah - 18-01-2020, 12:16 PM
RE: My new distro "Glacies" - by eadwardus - 19-01-2020, 02:20 PM
RE: My new distro "Glacies" - by josuah - 25-01-2020, 02:01 PM
|