Re: To Professor Daniel Bernstein: thanks for stralloc / array
[email protected] (Paul Jarc)
| Newsgroups | gmane.network.djbdns |
|---|---|
| Organization | What did you have in mind? A short, blunt, human pyramid? |
| Message-ID | <[email protected]> |
[email protected] wrote: > - programs using stralloc are immune to buffer overflows or reading > beyond the end of string, see qmail or other DJB software, Well, it's still possible to read or write beyond the end of a stralloc/array structure. But stralloc/array do make it easier to avoid doing that. > - it's binary safe, it can't be fooled by strings containing '\0's or > other garbage in the middle, True, although you still have to be careful when passing a stralloc-managed string to a function that just takes a char* argument. > Mr Bernstein please also consider adding stralloc_contains() and > stralloc_endswith() to your implementation. These are useful functions > which are trivial to implement. If you're looking for a somewhat more actively maintained implementation: http://www.skarnet.org/software/skalibs/libstddjb.html http://www.fefe.de/libowfat/ One problem with stralloc/gen_alloc is that if you use it for more than one array-element type, the object code is inflated, since there are separate function definitions for each type. The array interface solves that problem, but replaces it with the problem of not being type-safe. My vec library is inspired by stralloc/array, but solves both of these problems simultaneously - you only need one definition of the functions, but there are type-safe macros wrapping them. http://code.dogmap.org./prjlibs/c-vec/ paul