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.
John Marshall [Wed, 24 Jul 2013 13:08:25 +0000 (14:08 +0100)]
Only canonicalise if there is room, and add docs
We could increment SIZE to ensure there would be room, but that would
disadvantage people using kstrings for binary data in power-of-2-sized
blocks. Instead document that SIZE=KS.l+1 will ensure NUL-termination.
This fixes a bug in the previous version when the l<m invariant does not
hold (kputc_()/etc and manual manipulation only maintain the weaker l<=m);
hattip Rob Davies.
John Marshall [Tue, 23 Jul 2013 15:16:19 +0000 (16:16 +0100)]
ks_resize() canonicalises the stored string
It ensures the string is NUL-terminated, especially in the case that
ks_resize(&kstr,1) has been used on a newly-created kstring_t to ensure
that kstr.s is not NULL.
Yorhel [Tue, 7 May 2013 10:03:48 +0000 (12:03 +0200)]
kstring: Add printf format attribute to kvsprintf() and ksprintf()
This allows compile-time detection of format-string related bugs.
Although the macros only check for the GCC version, clang (and perhaps
other compilers too) have these macros defined and can recognize
the formatting attributes as well.
Russell Belfer [Fri, 31 Aug 2012 23:10:12 +0000 (16:10 -0700)]
Add khash wrapper around inline
As with allocation functions, when embedding khash inside another
library, the use of the non-portable "inline" keyword can be tricky.
Instead of adding a #define of inline, this adds "kh_inline" which
can be defined as needed inside khash with better isolation.
Russell Belfer [Fri, 31 Aug 2012 23:06:32 +0000 (16:06 -0700)]
Add allocation wrappers and error checking
When embedding khash in another project, it is convenient to be
able to replace the use of malloc/calloc/free with alternatives.
This wraps those calls with kmalloc/kcalloc/kfree, etc. macros
that can be easily redefined by the khash user to override the
allocators.
Additionally, the return value from allocations was not being
checked. This adds a check whenever an allocation is performed
and a return code of -1 to indicate an allocation failure.
Russell Belfer [Fri, 31 Aug 2012 23:01:27 +0000 (16:01 -0700)]
Reorganize khash decl macros to separate typedef
This separates the khash declaration macros into three pieces: one
to declare the type, one for the function prototypes, and one for
the function declarations. This makes it easier to instantiate a
khash type one time and have a header with just the typedef and
prototypes.
The old macros are redefined in terms of the new ones.
Heng Li [Mon, 30 Jul 2012 16:13:42 +0000 (12:13 -0400)]
Removed kfunc, kmin and krand
Each of these three libraries consists of a couple of hundred lines of code. I
think it does not harm too much if I put them together. I do not like too many
files...