Safe Strings project


Safe Strings is a small C library that handles C strings in a safe way. The functions of this library look at the necessary space for the operations and try to reserve that space (with malloc or realloc). The functions only begin working with their tasks when the memory allocation is successful.

The current release is the Version 2.0.1.

There are lots of changes from version 1.0.4. I tried to make a library that really is easy to use and I think that the first versions are not easy to use at all. Instead of handling with double pointers (which increases the risk of setting allocated pointers to NULL for example) I decided to create a String Object which contains information about the C-String like the length and the actual amount of allocated bytes for the string.

Using this design is much safer because once you've created a ss_string object the address of this object won't change anymore. All functions get a ss_string object as a parameter . If the address of the C-String in the object changes then the user won't have to worry about that. The SStrings functions do care about this and since the address of the object doesn't chage, you don't loose any pointer.

The functions do not expand the memory each time they are called. They calculate the number of bytes needed from the actual length and allocated bytes. If and only if the expected number of bytes is greater than the actual number of allocated bytes then the functions will expand the memory. On the other hand if the length of the string is lesser than a quarter of the actual number of allocated bytes then the functions will halve the number of allocated bytes.

Linking

If you use gcc and/or a gcc derivant you must link with the option -lsstrings

Online documentation

Online documentation for release 2.0.1

Contact & Bugs Report

Please contact me or send bug reports at yanezp (at) informatik.uni-freiburg.de
This site by freshmeat.net

Download

Version 2.0.1 *
README
BUGS
License
ChangeLog
sstrings-2.0.1.tar.gz [347 KB]
sstrings-2.0.1.tar.bz2 [234 KB]
Gentoo Ebuilds
RPM Version **

Version 1.0.4
sstrings-1.0.4.tar.gz [298 KB]

Version 1.0.3
sstrings-1.0.3.tar.gz [298 KB]

Version 0.0.2
sstrings-0.0.2.tar.gz [280 KB]

Version 0.0.1
sstrings-0.0.1.tar.gz [279 KB]

* This is the current release

** Maintained by Dries

Powered by freshmeat.net

Valid XHTML 1.0 Strict   Valid CSS!