On 25 February 2014 11:39, Dmitry Selyutin <[email protected]> wrote: > It's a pity that for language like C we generally don't have something > universal like Boost, so we have to implement some common functions from > scratch or introduce new dependencies. We have Glib, which is used mainly > by Gnome developers (though it is a standalone library) and LGPL-ed, which > is not as liberal as Boost's license. We also have APR, which seems to be a > bit more comprehensive and convenient, yet it is not so well-known as Glib. > I'm in process of implementing a something like Boost for ANSI C (though I > don't pretend this library to share Boost's comprehensiveness). Several > ideas I find useful are:
Well, what you'll find here in OpenBSD is that a lot of projects---and by that I mean those Open* ones affiliated with OpenBSD, or those maintained as part of src/ (core) to have some convention like xfoo() where foo() is some standard library which has been wrapped to provide additional checking/functionality. A good example of this is xmalloc() which tends to check the return value from malloc() as not NULL and acting accordingly. Are you saying your Quirinus library should help reduce this duplication? In terms of things like data structures, we have TAILQ, CIRCLEQ, and RB_TREES all of which are surprisingly not portable without the header files outside of BSD. Additionally, OpenBSD has things like strtonum(), strlcpy(), etc., all of which provide solutions to specific problems. How does your proposed library help unify these, seeing as they already exist? > 1. Strict and universal interface. Each function begins with qc_ prefix, That's more a naming convention than an interface. > followed by type if function is type-related. Most of types (except > enum-typedef'ed ones) have three common functions (replace _type_ with the > necessary type name, e.g. _bytes_): > a. Constructor: void * qc_type_construct(void). Allocate object instance > and initialize it to default value. > b. Destructor: void qc_type_destruct(void * pointer). Deallocate memory > allocated for object and its members. > c. Replicator: void * qc_type_replicate(void const * pointer). Replicate > object, copying its data to new allocated object, i.e. clone. Hmm. I am not sure I like this---but my immediate question is why is this better than what we have now, and where might you consider its replacement within OpenBSD to be beneficial? Do you have an example? > 2. Common and universal error type, qc_error. Such errors can be generated > from errno values as well as from Windows API errors. Welcome to strerrno() [...] -- Thomas Adam
