libds
SDS
Our great sponsors
libds | SDS | |
---|---|---|
6 | 48 | |
16 | 4,752 | |
- | - | |
0.0 | 0.0 | |
15 days ago | 6 months ago | |
C | C | |
MIT License | BSD 2-clause "Simplified" License |
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
libds
-
Common libraries and data structures for C
I may as well throw my hat into the ring: https://github.com/lelanthran/libds
I decided that I wanted to be able to simply drop a single .h file and a single .c file into any project without have to build a `libBlah.so` and link it to every project that needed (for example) a hashmap.
The practical result is that using the hashmap only requires me to copy the header and source files into the calling project.
It does build as a standalone library too, so you can link it if you want.
My primary reason for starting this is that I was pretty unsatisfied with all of the string libraries for C. When all I want to do is concatenate multiple strings together, I don't want to have to convert between `char ` and `struct stringtype ` everywhere.
The string functions are very useful as they all operate on the standard `char *` (nul-terminated) type.
-
Buffet
That would be nice, then I wouldn't have to use non-standard stuff.
I made my own easy-to-incorporate-into-any-project library - https://github.com/lelanthran/libds - just copy the ds_*.h and ds_*.c into a project and you're good to go.
I'm not saying it will work for you, but it works for me.
-
BCHS: OpenBSD, C, httpd and SQLite web stack
> Is there a good string-manipulation C library?
You will have to define "good". My string library[1][2] is "good" for me because:
1. It's compatible with all the usual string functions (doesn't define a new type `string_t` or similar, uses existing `char `).
2. It does what I want: a) Works on multiple strings so repeated operations are easy, and b) Allocates as necessary so that the caller only has to free, and not calculate how much memory is needed beforehand.
The combination of the above means that many common* string operations that I want to do in my programs are both easy to do and easy to visually inspect for correctness in the caller.
Others will say that this is not good, because it still uses and exposes `char *`.
[1] https://github.com/lelanthran/libds/blob/master/src/ds_str.h
[2] Currently the only bug I know of is the quadratic runtime in many of the functions. I intend to fix this at some point.
-
Strings in C... tiring and unsafe. So I just made this lib. Am I doing it right, Reddit ?
As an example of an opaque pointer library, see https://github.com/lelanthran/libds/blob/v1.0.5/src/ds_ll.h - See line 7 for the typedef. - Lines 9, 10, 11 and 67, 68 and 69 for making it callable from C++.
I've done the same thing for my array library - use the first 4 bytes for the length, and everywhere else it behaves like a normal array (https://github.com/lelanthran/libds/blob/v1.0.5/src/ds_array.c)
So, I wrote a new library recently that works produces and consumes strings in the form that C already uses them in (making them more easily usable everywhere) - https://github.com/lelanthran/libds/blob/v1.0.5/src/ds_str.h
SDS
-
Safest way to copy a string?
Even better, use a string handling library. Personally I am a big fan of (sds)[https://github.com/antirez/sds] from the Redis creator. It's not even a dependancy you can just copy the .c and .h to your project.
-
New C features in GCC 13
One nice application is length-prefixed string literals to complement dynamic string libraries:
-
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 the world is sort of written on it!
Just yesterday I needed to parse a JSON… found a bunch of libraries that do that and just picked one that I liked the API.
-
C_dictionary: A simple dynamically typed and sized hashmap in C - feedback welcome
d) everything being a macro seems overkill for me (and possibly dangerous, see b)). Maybe implement more as static inline functions, see the sds header: https://github.com/antirez/sds/blob/master/sds.h (which does a similar thing with the header struct).
-
Updated book to learn C
For example, you can use the C language with sds strings (see https://github.com/antirez/sds) if you want to have an easier time with string formatting and don't want to worry about using the famously unsafe string.h functions correctly. You'll still program in ISO C, but just not in the standard library. The same applies to pretty much all parts of the standard library, the only part unsurpassed is pretty much just printf and the math headers (math.h, fenv.h, tgmath.h, complex.h) imo, and the occasional call to exit. A good place to look for libraries if you want to go that route is the awesome-c collection: https://github.com/oz123/awesome-c
-
Convenient Containers: A usability-oriented generic container library
One way around this problem is to declare the container as a pointer to the element type and then store the container’s metadata, alongside its elements, in the heap block to which the pointer points. This approach is already used for dynamic arrays in several container libraries, most notably stb_ds and sds. They place the metadata before the elements and provide the user with a pointer to the elements themselves (this has the nice effect that users can use the [] operator to access elements).
-
A convenient C string API, friendly alongside classic C strings.
Simple Dynamic Strings library for C
The canonical library for this is SDS. Any new claimant to the C-string throne should explain the advantages/disadvantages/trade-offs of its use in comparison to SDS.
-
Show HN
I always use antirez's (Redis creator) `sds` and advertise it whenvever I get the chance. It's a joy to use :
https://github.com/antirez/sds
From the Readme:
```
-
Is there a convention for "private" struct members?
The approach you suggest works in some cases, but I don't think the one you suggest is very good. I think a good example of such use, is sds string. He uses a hidden prefix, instead of suffix, but that is just an implementation detail. It works because he is returning a pointer to the user data. However, sds string should only be manipulated via functions, while user data can be manipulated like C strings. There is only one public header, but what user is concern with, is just the opaque pointer 'sds', which is manipulated by functions, so those structs that sds string are could as well be in a private header.
What are some alternatives?
Better String - The Better String Library
Experimental Boost.MSM-lite - Boost.SML (formerly called Boost.MSM-lite)
libcpuid - a small C library for x86 CPU detection and feature extraction
ZXing - ZXing ("Zebra Crossing") barcode scanning library for Java, Android
STX - C++17 & C++ 20 error-handling and utility extensions.
safestringlib
stb - stb single-file public domain libraries for C/C++
C++ Format - A modern formatting library
DynaMix - :fish_cake: A new take on polymorphism
Serial Communication Library - Cross-platform, Serial Port library written in C++
RE2 - RE2 is a fast, safe, thread-friendly alternative to backtracking regular expression engines like those used in PCRE, Perl, and Python. It is a C++ library.
SLRE - Super Light Regexp engine for C/C++