(set them to the null pointer instead).
Thus, code that doesn't specificallly attempt to clean up allocated
memory after an error result is returned from yp_...() won't have an
unexpected memory leak (i.e, most 3rd party code)
calls is initialised to the null pointer so that the error condition
doesn't fail by trying to free() memory that wasn't malloc()ed
* cleanup a bit; remove use of register, KNFify
to the null pointer before invocation, so that the test in the
error case of "if (outdata != NULL) free(outdata)" won't potentially
try and free memory that wasn't malloc()ed.
* factor some duplicated code out of both parts of an "if {} else {}"
construct.
* remove use of `register' & KNFify.
* Ensure that all 'char **outXXX' pointers aren't the null pointer before use.
* Set *outXXX=NULL before checking any other arguments.
* Document that *outXXX will always be NULL or a malloc(3)ed string
unless outXXX was NULL (in which case YPERR_BADARGS will be returned
and the caller shouldn't attempt to free(*outXXX) if *outXXX != NULL;
These changes should prevent most occurances of coredumps when a bad
argument was given to a yp client function and the caller attempts to
free an outvalue that isn't the null pointer. To be really safe, the
caller probably should set the *outvalue=NULL anyway (ref: PR [lib/3580])
This code uses subb instead of cmpb to compare chars. When they are
not equal, the function's return value is computed by sign extending
the difference. The basic idea was contributed by Hiroshi Horitomo
<horimoto@cs-aoi.cs.sist.ac.jp> in PR #3223, but his implementation
used additional instructions to compute the return value.
Also, the series of insns used to compare one pair of characters has
been unrolled 4 times. This helps the 680[23]0, where the cost of a
taken branch is significantly more than that of a not-taken branch.
The implementation of these functions is losely based on the original
BSD code plus versions I was working on which would yeild code tuned
for a particular m68k or coldfire family cpu, code space or run time
efficiency, etc. depending on the values of various macros.
My original code was intended for use in OS-less embedded systems.
Because NetBSD can not benefit from the considerable complexity, I've
removed the extraneous preprocessor goop. The resulting code is tuned
for the '020 - '060. It will not function on the '000 or coldfire.