Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Library functions

Name: Anonymous 2007-11-05 15:34

If we are writing a library with a function that should ultimately return a string of varying size, could be anything from several thousand KB or a few bytes.

Do you prefer if the function returns the string or manipulates a pointer argument to return the string? Or perhaps both?

If it were to return the string then of course it would have to return NULL on failure and perhaps set some global error variable, maybe errno.

But if it were to simply manipulate a pointer argument and put the string in there then it could return integer error codes.

I'm asking what you as C programmers prefer because this is my first real open source project and it will be a programming library put up for public use.

Personally, i think i'd prefer if the function only returned the pointer because in this case it must also take a struct argument.

This is the kind of pointless question i would only dare ask on an anonymous board for fear of humiliation among my cybernets peers.

Name: Anonymous 2007-11-05 16:26

>>3
He's choosing to limit himself to C, for what I can only assume are bad reasons. C is great for OS implementation and device drivers, but shit for string processing. Historically, he should be using something like Snobol or Icon; or nowadays Perl is probably the best choice.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List