John Marshall [Tue, 24 Mar 2015 09:37:12 +0000 (09:37 +0000)]
Prevent unused function warnings in khash.h, klist.h
Recent versions of Clang warn about unused static inline functions
in .c files (though they suppress this warning for such definitions
in header files). Definitions via KHASH_INIT etc are effectively in
the .c file, and it's impractical to make these inline other than
static inline; so add attributes to suppress these warnings.
John Marshall [Tue, 9 Jun 2015 02:29:54 +0000 (03:29 +0100)]
Add kgetline() to kstring.c/.h
Similar to BSD's getline() but omits the \n terminator and manages the
memory as a kstring. Call with "(kgets_func *) fgets" to read from stdio,
or implement an fgets()-style function to read from other streams, e.g.,
a wrapper around gzgets() that reorders its parameters as per fgets().
John Marshall [Wed, 12 Mar 2014 14:33:12 +0000 (14:33 +0000)]
Add ks_release() to kstring.h
Using this function is a more explicit way of transferring ownership
than just "foo = str.s"; the latter leaves room for readers to wonder
whether a subsequent "free(str.s)" has been forgotten.
John Marshall [Thu, 13 Nov 2014 14:28:46 +0000 (14:28 +0000)]
Fix ks_getuntil2() extra empty record at EOF bug
When the stream is an exact multiple of the buffer size, ks_getuntil2()
was returning a final empty record when it should have returned -1.
Fixed by moving the "EOF => return -1" check to after the read loop.
(See samtools/samtools#318 for an example of an error caused by a
spurious empty line at the end of a SAM file.)
John Marshall [Wed, 9 Apr 2014 12:40:34 +0000 (13:40 +0100)]
Silence -Wstrict-prototypes and static analyser warnings
Using "(void)" provides an explicit there-are-no-arguments prototype.
Using the exact type in "malloc(...sizeof)" is clearer and silences
warnings from clang's static analyzer.
zhanxw [Sat, 30 Nov 2013 04:37:10 +0000 (23:37 -0500)]
Update ksort.h
From my personal communication, I got this suggestion:
using inline incorrectly: see the C99 standard ยง6.7.4. Please change to static inline (and report upstream). This also caused some clang compilation problem.
Heng Li [Tue, 19 Nov 2013 03:07:40 +0000 (22:07 -0500)]
need to grow buffer
One multi_perform() frequently invokes multiple write_cb(). We have to use a
dynamic buffer. Hmm.. I really do not like the curl APIs, although I understand
why they are designed this way.
Heng Li [Mon, 18 Nov 2013 20:29:18 +0000 (15:29 -0500)]
Fixed slow sftp/scp connection
In curl/docs/examples/fopen.c, the developer didn't check maxfd set by
curl_multi_fdset() and supposed that calling select(0,...) is effectively
equivalent to sleep. While the comment is correct, timeout estimated by
curl_multi_fdset() is frequently too large - in my case 10 seconds. We seldom
need to wait that long.
In curl_multi_fdset.3, the cURL developers recommended to wait at least 100ms
if maxfd is set to 1. This is what I am doing in the revised code. It does
little harm.