Tarsnap/libcperciva
View on GitHub ↗ ★ 116 C
BSD-licensed C99/POSIX library code shared between tarsnap, scrypt, kivaloo, spiped, and bsdiff.
12 mentions on Hacker News by 5 people: 1 story, 11 comments · first 2016-01-18 · latest 2025-05-13
20082026
-
With a few more clever tricks... I did this with my PARSENUM macro ( https://github.com/Tarsnap/libcperciva/blob/master/util/pars... ) to parse strings into floating-point, unsigned integer, or signed integer types (and check bounds) using…
comment by cperciva · 2025-05-13 · in Detecting if an expression is constant in C -
https://github.com/Tarsnap/libcperciva/blob/master/util/geto... https://github.com/Tarsnap/libcperciva/blob/master/util/geto... BSD licensed, of course.
comment by cperciva · 2023-01-05 · in C Posix-compliant argument parsing in 42 LoC, inspired by Duff's device -
See also "elastic arrays": https://github.com/Tarsnap/libcperciva/blob/master/datastruc... https://github.com/Tarsnap/libcperciva/blob/master/datastruc... ELASTICARRAY_DECL(STR, str, char); creates a type "STR" and the functions str_init,…
comment by cperciva · 2021-04-09 · in Type-safe generic data structures in C -
…the topic of compilers being hard: In my repositories I'm carrying around a 5 year old workaround ( https://github.com/Tarsnap/libcperciva/commit/92e666e59503de... ) for a 6 year old bug ( https://bugs.llvm.org/show_bug.cgi?id=21183 ) in…
comment by cperciva · 2021-01-21 · in Compilers are hard -
realloc(foo, 0) was changed to no longer free in C99. A rant on the subject: https://github.com/Tarsnap/libcperciva/commit/cabe5fca76f6c3...
comment by slavik81 · 2020-04-15 · in Tell HN: C Experts Panel – Ask us anything about C -
…the common cases of parsing human-readable values while appropriately checking for overflow ( https://github.com/Tarsnap/libcperciva/blob/master/util/pars... ).
comment by cperciva · 2020-01-30 · in Let's Destroy C -
Here's an example: https://github.com/Tarsnap/libcperciva/blob/master/datastruc... As long as you invoke use it properly, e.g. ELASTICARRAY_DECL(PTRLIST, ptrlist, void *); there's no way it will create non-compliant code.
comment by cperciva · 2019-07-06 · in So you think you know C? (2016) -
…easier, not harder, to understand . A few examples from my own code: 1. My "elastic arrays" ( https://github.com/Tarsnap/libcperciva/blob/master/datastruc... and .c) allow me to write ELASTICARRAY_DECL(STRLIST, strlist, const char *); and…
comment by cperciva · 2017-03-16 · in Principles for C programming -
…computed goto in order to work around a bug in LLVM's handling of sigsetjmp/siglongjmp: https://github.com/Tarsnap/libcperciva/commit/92e666e59503de... 4. Many years ago, I added a spurious 'volatile' into some Tarsnap code in order to…
comment by cperciva · 2016-09-12 · in Ask HN: Strange bug workarounds? -
> Wrong! https://github.com/Tarsnap/libcperciva/commit/cabe5fca76f6c3... . No, of course not "Wrong!" If a user of a library wants to supply their own allocator, they must provide a version of realloc that acts as free() for the (p,0)…
comment by eps · 2016-03-13 · in Collections-C, generic data structures for C -
…to rethink everything from the bottom up. when all you need is just a pointer to realloc Wrong! https://github.com/Tarsnap/libcperciva/commit/cabe5fca76f6c3...
comment by seiji · 2016-03-13 · in Collections-C, generic data structures for C -
▲ 142
Once upon a time, memory allocators made sensestory by dchest · 2016-01-18 · 117 comments