100 Commits

Author SHA1 Message Date
Sun He
84ee8268c7 sds.c: Correct some comments 2014-11-02 10:40:28 +08:00
Ted Nyman
39be4bf496 Fix on-place -> in-place
Closes #1373
2014-09-29 06:49:07 -04:00
Lynn
74aeb27a26 Remove surplus double quotes
Closes #1877
2014-09-29 06:49:05 -04:00
antirez
8eeb1802ec No longer useful assert removed from sdsIncrLen(). 2014-08-25 10:36:26 +02:00
antirez
68db7b1f56 Use unsigned integers in SDS header.
This raises the max string to 4GB without any downside.
2014-08-13 10:53:51 +02:00
Pieter Noordhuis
cf85b5ba81 va_copy must be matched by va_end
Hat tip to @rfuchs. See: https://github.com/redis/hiredis/pull/178.

Fixes #1187
2014-08-12 11:50:02 +02:00
antirez
95b1979c32 No more trailing spaces in Redis source code. 2014-06-26 18:48:40 +02:00
antirez
be8f4d49d4 Silence different signs comparison warning in sds.c. 2014-06-23 11:50:24 +02:00
antirez
2d76736a2e Added new sdscatfmt() %u and %U format specifiers.
This commit also fixes a bug in the implementation of sdscatfmt()
resulting from stale references to the SDS string header after
sdsMakeRoomFor() calls.
2014-04-28 16:38:17 +02:00
antirez
53575c4708 sdscatfmt() added to SDS library.
sdscatprintf() relies on printf() family libc functions and is sometimes
too slow in critical code paths. sdscatfmt() is an alternative which is:

1) Far less capable.
2) Format specifier uncompatible.
3) Faster.

It is suitable to be used in those speed critical code paths such as
CLIENT LIST output generation.
2014-04-28 16:23:17 +02:00
antirez
30639c8ca9 sdscatvprintf(): Try to use a static buffer.
For small content the function now tries to use a static buffer to avoid
a malloc/free cycle that is too costly when the function is used in the
context of performance critical code path such as INFO output generation.

This change was verified to have positive effects in the execution speed
of the INFO command.
2014-03-24 10:20:33 +01:00
antirez
a9caca0424 sdscatvprintf(): guess buflen using format length.
sdscatvprintf() uses a loop where it tries to output the formatted
string in a buffer of the initial length, if there was not enough room,
a buffer of doubled size is tried and so forth.

The initial guess for the buffer length was very poor, an hardcoded
"16". This caused the printf to be processed multiple times without a
good reason. Given that printf functions are already not fast, the
overhead was significant.

The new heuristic is to use a buffer 4 times the length of the format
buffer, and 32 as minimal size. This appears to be a good balance for
typical uses of the function inside the Redis code base.

This change improved INFO command performances 3 times.
2014-03-24 09:44:11 +01:00
codeeply
0f06f8df07 comment mistake fixed 2013-12-12 16:33:29 +08:00
antirez
11e81a1e9a Fixed grammar: before H the article is a, not an. 2013-12-05 16:35:32 +01:00
antirez
6ea8e0949c sdsrange() does not need to return a value.
Actaully the string is modified in-place and a reallocation is never
needed, so there is no need to return the new sds string pointer as
return value of the function, that is now just "void".
2013-07-24 11:21:39 +02:00
antirez
076c2623ac Every function inside sds.c is now commented. 2013-07-23 16:35:55 +02:00
antirez
585b0a61ce sds.c: new function sdsjoin() to join strings. 2013-07-04 18:30:59 +02:00
antirez
729a3432ba sds.c: sdssplitargs_free() removed as it was a duplicate. 2013-03-06 12:38:06 +01:00
antirez
4ea89e64c0 sdssplitargs(): on error set *argc to 0.
This makes programs not checking the return value for NULL much safer
since with this change:

1) It is still possible to iterate the zero-length result without
crashes.
2) sdssplitargs_free will work against NULL and 0 count.
2013-03-06 12:21:31 +01:00
antirez
5cabae84e6 sdssplitargs(): now returns NULL only on error.
An empty input string also resulted into the function returning NULL
making it harder for the caller to distinguish between error and empty
string without checking the original input string length.
2013-03-06 12:21:21 +01:00
guiquanz
9d09ce3981 Fixed many typos. 2013-01-19 10:59:44 +01:00
antirez
4365e5b2d3 BSD license added to every C source and header file. 2012-11-08 18:31:32 +01:00
Erik Dubbelboer
0a2ff52eae Added consts keyword where possible 2012-03-30 21:19:51 +02:00
antirez
739803c064 sds.c: sdsAllocSize() function added. 2012-03-14 14:58:26 +01:00
antirez
9555f8f21b sds.c new function sdsRemoveFreeSpace().
The new function is used in order to resize the string allocation so
that only the minimal allocation possible is used, removing all the free
space at the end of the string normally used to improve efficiency of
concatenation operations.
2012-03-14 10:13:23 +01:00
antirez
1596d6a61e Obsolete SDS_ABORT_ON_OOM removed from sds.c 2012-01-16 10:08:33 +01:00
antirez
bd068b15c2 sds.c no longe pre-allocate more than 1MB of free space ahead. This fixes issue #252. 2012-01-16 10:03:38 +01:00
antirez
08a879af6e Added sdscatsds() to sds.c/h 2011-11-21 15:34:00 +01:00
antirez
d0b2a9b223 sdsMakeRoomFor() exposed as public API. sdsIncrLen() added. Both the changes make it possible to copy stuff from a system call to an sds buffer without the need of an additional buffer and copying overhead. 2011-11-02 16:50:59 +01:00
antirez
3526724594 added a comment to sdsMakeRoomFor() to make it clear what the function actually does. 2011-11-02 16:09:14 +01:00
antirez
e1cf460cf1 sds.c single quotes support 2011-10-28 17:31:40 +02:00
Pieter Noordhuis
f990782f4d Re-use AOF buffer when it is small enough 2011-09-13 12:22:54 +02:00
antirez
3bb818df40 Make sure error and status replies emitted by Lua scripts can never have more than a newline, otherwise it is a protocol violation and clients will desync. 2011-05-25 12:32:50 +02:00
Pieter Noordhuis
c040cbd625 Check seplen and len before malloc'ing "tokens" 2011-05-05 16:32:22 +02:00
Pieter Noordhuis
ded614f803 Inline sdslen and sdsavail (thanks to @bitbckt) 2011-05-05 16:25:48 +02:00
antirez
726a39c15f initial cluster config load code 2011-04-07 12:55:02 +02:00
antirez
626f6b2d64 DUMP implemented, RESTORE and MIGRATE fixed. Use zcalloc() instead of zmalloc()+memset() in sds.c when a new string is created with NULL initialization pointer. 2011-04-01 18:59:28 +02:00
antirez
e360e3bb7e Fixed sdssplitargs() handling of hex-style escapes. 2011-03-22 22:49:12 +01:00
antirez
612810af6e sdscatrepr() fixed. Now newlines and other special chars are escaped correctly 2011-03-20 18:24:49 +01:00
antirez
be86082be4 Fixed a theoretical non exploitable security bug reported by @chrisrohlf. In theory if we undefine SDS_ABORT_ON_OOM from sds.c AND modify zmalloc.c in order to don't quit on out of memory (but this would break every other part of Redis), on out of memory there is a possible heap overflow. 2011-01-27 10:27:25 +01:00
Pieter Noordhuis
cc20906390 Change function name to match what it does 2010-12-10 12:16:16 +01:00
Pieter Noordhuis
eae33c1c81 Add generic function to grow an sds value
Move logic concerned with setting a bit in an sds to the SETBIT command
instead of keeping it in sds.c. The function to grow an sds can and will
be reused for a command to set a range within a string value.
2010-12-10 11:58:21 +01:00
Pieter Noordhuis
3c1bf4957e Add commands SETBIT/GETBIT 2010-12-09 16:39:33 +01:00
antirez
963238f713 more tests for sds.c 2010-09-23 16:39:02 +02:00
antirez
136cf53f22 minimal C test framework + a first example sds.c tests 2010-09-23 16:05:17 +02:00
Pieter Noordhuis
60361e5aac Add sds function that can be called with va_list 2010-09-02 21:00:15 +02:00
Pieter Noordhuis
2929ca9786 Fix parenthesis error on decrementing *argc 2010-08-26 13:18:44 +02:00
Pieter Noordhuis
4b93e5e267 Merge master and move argument splitting patch to sds.c 2010-08-25 13:08:43 +02:00
antirez
cbce517145 redis cli argument splitting is general and is now moved into the sds.c lib 2010-08-05 11:36:39 +02:00
antirez
e2641e09cc redis.c split into many different C files.
networking related stuff moved into networking.c

moved more code

more work on layout of source code

SDS instantaneuos memory saving. By Pieter and Salvatore at VMware ;)

cleanly compiling again after the first split, now splitting it in more C files

moving more things around... work in progress

split replication code

splitting more

Sets split

Hash split

replication split

even more splitting

more splitting

minor change
2010-07-01 14:38:51 +02:00