antirez/sds
View on GitHub ↗ ★ 5,588 C
Simple Dynamic Strings library for C
67 mentions on Hacker News by 50 people: 7 stories, 60 comments · first 2014-02-06 · latest 2026-10-15
20082026
-
libsds - Simple Dynamic Strings https://github.com/antirez/sds
comment by Kevin_Flynn · 2026-10-15 · in Why C Strings Suck and How I Fixed Them -
Hacker News seems not to hate antirez's sds https://github.com/antirez/sds https://news.ycombinator.com/item?id=45014911
comment by krapp · 2026-02-08 · in I write games in C (yes, C) (2016) -
…consider a must-have in any modern project. Also probably something similar for C, like using SDS ( https://github.com/antirez/sds ) instead of standard library calls. Other than that, great work.
comment by pjmlp · 2026-01-23 · in Show HN: C/C++ Cheatsheet – a modern, practical reference for C and C++ -
Since I am feeling generous, here are two examples, https://docs.gtk.org/glib/ https://github.com/antirez/sds
comment by pjmlp · 2026-01-06 · in C Is Best (2025) -
…to add in the header would be a strlen The length is already in the header from what I can tell: https://github.com/antirez/sds/blob/master/sds.h#L64 But my point was that if something like your "free count" byte existed at the end, I…
comment by ranger_danger · 2025-07-19 · in Making a StringBuffer in C, and questioning my sanity -
You might be interested in https://github.com/antirez/sds
comment by ranger_danger · 2025-07-18 · in Making a StringBuffer in C, and questioning my sanity -
…are quite a few of these "better C string" idioms floating around. Another one to consider is e.g. https://github.com/antirez/sds (used by Redis), which instead stores the string contents in-line with the metadata.
comment by simscitizen · 2024-12-17 · in Fixing C Strings -
…Str: https://cii.s3.amazonaws.com/book/pdf/quickref.pdf [2] ICU - https://icu.unicode.org [3] SDS - https://github.com/antirez/sds [4] GLib - https://docs.gtk.org/glib/struct.String.html
comment by jll29 · 2024-07-30 · in C Macro Reflection in Zig -
…for C; sometimes I feel everyone has gone and invented their own. Antirezs sds is just one example https://github.com/antirez/sds
comment by zokier · 2024-07-15 · in I'm not a fan of strlcpy(3) -
Is [b] https://github.com/antirez/sds ?
comment by nesarkvechnep · 2024-05-27 · in The CompCert C Compiler -
…including interoperability with null-terminated C strings. Like this one used in Redis: https://github.com/antirez/sds And on top of everything else, it's quite ergonomic, so it seems silly to not consider it. This entire line of thinking…
comment by jchw · 2023-07-18 · in Strlcpy and strlcat added to glibc 2.38 -
…exist, without vocabulary types on the stardard library adoption will never take off. [0] - https://github.com/antirez/sds [1] - https://en.wikipedia.org/wiki/Abstract_data_type
comment by pjmlp · 2023-04-25 · in Strlcpy and Strlcat – Consistent, Safe, String Copy and Concatenation (1999) [pdf] -
The creator of this library (antirez) is a regular here on hn. I believe this is used by Redis. https://github.com/antirez/sds
comment by epr · 2023-04-06 · in C Strings and my slow descent to madness -
> With the woes of string.h being known, why not just use an alternative like https://github.com/antirez/sds ? That library really doesn't address any of the Unicode issues.
comment by kerkeslager · 2023-04-06 · in C Strings and my slow descent to madness -
With the woes of string.h being known, why not just use an alternative like https://github.com/antirez/sds ? I’ve also been having a blast with C because writing C feels like being a god! But the biggest thing that I like about C is that…
comment by _benj · 2023-04-06 · in C Strings and my slow descent to madness -
…I get the chance. Thanks to the someone who recommended it on HN some years ago. It's a joy to use. https://github.com/antirez/sds The trick is the size is hidden before the adress of the buffer.("Learn this one simple trick that will…
comment by cassepipe · 2022-12-03 · in Show HN: A nice C string API -
https://github.com/antirez/sds
comment by rabf · 2022-08-27 · in Ushering out strlcpy() -
…something like SDS[0] as part of the standard library, but that is clearly asking too much. [0] - https://github.com/antirez/sds
comment by pjmlp · 2022-08-05 · in C23 is finished: Here is what is on the menu -
have you looked into sds: https://github.com/antirez/sds/
comment by latenightcoding · 2022-03-08 · in Buffet – An All-inclusive Buffer for C -
Yes, SDS from Redis project. https://github.com/antirez/sds However the moment you call into other C libraries, they naturally only expect a char *.
comment by pjmlp · 2022-01-19 · in BCHS: OpenBSD, C, httpd and SQLite web stack -
…such as sds. But really the point was more to "this should have really been addressed decades ago." https://github.com/antirez/sds
comment by kortex · 2021-07-31 · in Strict memcpy() bounds checking for the Linux kernel -
…if I really must write C, then a string handling library like the SDS from Redis project is a must. https://github.com/antirez/sds Naturally turning on all security features of the C compiler being used, warnings, warnings as errors,…
comment by pjmlp · 2021-07-31 · in strcpy: A niche function you don't need -
…string-handling libraries in C that avoid those problems (e.g., http://bstring.sourceforge.net/ or https://github.com/antirez/sds ). But the fact remains that the kernel has its own implementations of strcat and sprintf nonetheless (in the…
comment by geofft · 2021-07-06 · in Linux Rust Support -
You might look at SDS. https://github.com/antirez/sds
comment by macintux · 2021-06-19 · in Designing a better strcpy -
You should also have a look the simple yet efficient sds : https://github.com/antirez/sds
comment by cassepipe · 2021-05-19 · in Chad Strings – The Chad way to handle strings in C -
…you would also expect that by now something like SDS would be part of the standard as well. https://github.com/antirez/sds
comment by pjmlp · 2021-05-08 · in The Byte Order Fiasco -
You may find some inspiration for improvements from this project: https://github.com/antirez/sds
comment by 0xdeaddeaf · 2021-03-26 · in Show HN: Stricks – managed C strings library -
…my invention ! Alas it was at least used in Microsoft' BSTR and later by the famous antirez/sds ( https://github.com/antirez/sds ) > no nested macros I hear you. I thought it made them more readable. > is all that's going on I also (maybe…
comment by alcover · 2021-03-25 · in Show HN: Stricks – managed C strings library -
Strings have nothing to do with objects. You can write a string library, eg. [sds]( https://github.com/antirez/sds ). It's just not standard.
comment by c-cube · 2021-03-04 · in Git's list of banned C functions -
…(MITish) * https://github.com/mpedrero/safeString (MIT licensed) * https://github.com/antirez/sds (BSD 2-clause, and gives you dynamic strings) * https://github.com/maxim2266/str (BSD 3-clause) * https://github.com/xyproto/eg
comment by cestith · 2021-03-04 · in Git's list of banned C functions -
I'm partial to https://github.com/antirez/sds these days
comment by swlkr · 2021-03-04 · in Git's list of banned C functions -
…sds that store the length information in various ways, which solves at least this kind of problem. https://github.com/antirez/sds
comment by cormacrelf · 2021-03-02 · in Parsing can become accidentally quadratic because of sscanf -
…be a pity not to mention here the Simple Dynamic String (SDS) library made by the maker of Redis : https://github.com/antirez/sds It is also very well documented. And all you need to embed it in your project is : sds.c sds.h sdsalloc.h The…
comment by cassepipe · 2020-11-26 · in Str: Yet another string library for C language -
…of the same features (not all), and is kept updated since it's used by redis and other projects. https://github.com/antirez/sds/blob/master/README.md Vstr appears to have last been updated in 2006. It does have a comparison of different…
comment by tyingq · 2020-03-10 · in Vstr: C string library designed to work optimally with vector I/O -
https://github.com/antirez/sds is heaps better than just using raw strings. Any language with a fat pointer variant out of the box is going to do it better than C as well. That's not to say that the rest of C is bad, but there's nothing to…
comment by 59nadir · 2019-12-26 · in I love coding in C -
…Obviously you can misuse anything, but SDS is easy to use correctly. It's robust enough for Redis. https://github.com/antirez/sds
comment by tlb · 2019-09-21 · in Why I Write Games in C (yes, C) -
…and it was not prohibitively difficult. Something like this probably covers most use cases: https://github.com/antirez/sds
comment by Steven_Vellon · 2019-09-12 · in Efficient string copying and concatenation in C -
sds (simple dynamic strings) is a decent compromise: https://github.com/antirez/sds (used in redis)
comment by tyingq · 2019-09-12 · in Efficient string copying and concatenation in C -
sds comes to mind, but there are like gazillion different implementations of the same concept. https://github.com/antirez/sds
comment by zokier · 2019-09-12 · in Efficient string copying and concatenation in C -
…have succeeded, obviously. There are a number of alternative string libraries, though; here's one: https://github.com/antirez/sds . And I'm sure some programmers would suggest C++ as the real "effort to add real string types and maybe…
comment by saagarjha · 2019-08-26 · in Why is strlen so complex in C? -
https://github.com/antirez/sds
comment by ayosec · 2019-08-25 · in Banned C standard library functions in Git source code -
Salvatore Sanfilippo, from Redis fame, has a nice one https://github.com/antirez/sds .
comment by vmsp · 2019-08-25 · in Banned C standard library functions in Git source code -
Also sds, used by redis: https://github.com/antirez/sds
comment by tyingq · 2019-04-25 · in Some Were Meant for C (2017) [pdf] -
> but you'll be incompatible with any code dealing with native C-strings Not entirely, see https://github.com/antirez/sds Basically, you have a header storing length, etc, but still null terminate, so library functions like strlen are none…
comment by paavoova · 2018-12-15 · in String tokenization in C -
Sds is somewhat nice in that you can work both ways. https://github.com/antirez/sds
comment by tyingq · 2018-11-03 · in How to implement strings -
…their own array type that knows its length, and use it in their projects. See this for example: https://github.com/antirez/sds
comment by kahlonel · 2018-07-22 · in Conflating pointers with arrays: C's biggest mistake? (2009) -
…than a language I could use for simple general purpose programs(that are still as fast as C). [1] - https://github.com/antirez/sds EDIT : Grammar and reference
comment by reacharavindh · 2018-05-24 · in Ask HN: Why is there not a memory-safe C? -
Basically this: https://github.com/antirez/sds
comment by zzzcpan · 2018-03-15 · in Checked C: extension to C that adds static and dynamic checking