63 Commits

Author SHA1 Message Date
FuGangqiang
a67aedb738 sdsfree x and y 2015-04-20 23:03:34 +08:00
FuGangqiang
7a92c11797 fix doc example 2015-04-20 21:46:48 +08:00
FuGangqiang
4e5b058ed0 fix typo 2015-04-19 23:42:27 +08:00
antirez
28e8878baa sdsnative() removed: New rdb.c API can load native strings. 2015-01-08 09:52:44 +01:00
Matt Stancliff
2133073bb8 Add sdsnative()
Use the existing memory space for an SDS to convert it to a regular
character buffer so we don't need to allocate duplicate space just
to extract a usable buffer for native operations.
2015-01-02 11:16:08 -05:00
Matt Stancliff
d2356d1ce7 Allow all code tests to run using Redis args
Previously, many files had individual main() functions for testing,
but each required being compiled with their own testing flags.
That gets difficult when you have 8 different flags you need
to set just to run all tests (plus, some test files required
other files to be compiled aaginst them, and it seems some didn't
build at all without including the rest of Redis).

Now all individual test main() funcions are renamed to a test
function for the file itself and one global REDIS_TEST define enables
testing across the entire codebase.

Tests can now be run with:
  - `./redis-server test <test>`

  e.g. ./redis-server test ziplist

If REDIS_TEST is not defined, then no tests get included and no
tests are included in the final redis-server binary.
2014-12-23 09:31:03 -05:00
antirez
070ec599ba sdsformatip() removed.
Specialized single-use function. Not the best match for sds.c btw.
Also genClientPeerId() is no longer static: we need symbols.
2014-12-11 18:29:04 +01:00
Matt Stancliff
89d35a3391 Add centralized IP/Peer formatting functions
This stops us from needing to manually check against ":" to
add brackets around IPv6 addresses everywhere.
2014-12-11 10:05:35 -05:00
antirez
b06903493f Merge branch 'unstable' of github.com:/antirez/redis into unstable 2014-12-10 09:51:00 +01:00
antirez
1a5d6bf9f8 sds.c: more tests for sdstrim(). 2014-12-10 09:48:56 +01:00
Brochen
3b452712ea Update sds.c
in the case (all chars of the string s found in 'cset' ),
line[573] will no more do the same thing line[572] did.
this will be more faster especially in the case that the string s is very long and all chars of string s found in 'cset'
2014-12-10 11:19:13 +08:00
Sun He
22230af4c9 sds.c: Correct two spelling mistakes in comments 2014-11-03 17:21:54 +08:00
Sun He
feee9c753a sds.c/sdscatvprintf: set va_end to finish va_list cpy 2014-11-02 10:42:26 +08:00
Sun He
d9ae8b358b sds.c: Correct some comments 2014-11-02 10:40:28 +08:00
Ted Nyman
b1fd6d35c6 Fix on-place -> in-place
Closes #1373
2014-09-29 06:49:07 -04:00
Lynn
b984044c0c Remove surplus double quotes
Closes #1877
2014-09-29 06:49:05 -04:00
antirez
5e780be2ad No longer useful assert removed from sdsIncrLen(). 2014-08-25 10:36:26 +02:00
antirez
02b06ba8f0 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
de398a534e 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
1c94889182 No more trailing spaces in Redis source code. 2014-06-26 18:48:40 +02:00
antirez
82d95f85f8 Silence different signs comparison warning in sds.c. 2014-06-23 11:50:24 +02:00
antirez
de11c325ae 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
8e7e7cc5eb 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
e2c6bb0a2a 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
57e4d0ca6b 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
45637a3a82 comment mistake fixed 2013-12-12 16:33:29 +08:00
antirez
7a5a646df9 Fixed grammar: before H the article is a, not an. 2013-12-05 16:35:32 +01:00
antirez
fc11a99390 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
02a22c9be1 Every function inside sds.c is now commented. 2013-07-23 16:35:55 +02:00
antirez
de40c9df4f sds.c: new function sdsjoin() to join strings. 2013-07-04 18:30:59 +02:00
antirez
478915f6c7 sds.c: sdssplitargs_free() removed as it was a duplicate. 2013-03-06 12:38:06 +01:00
antirez
4b0a5fc539 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
67b7fcdc08 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
df7a5b7157 Fixed many typos. 2013-01-19 10:59:44 +01:00
antirez
a32d1ddff6 BSD license added to every C source and header file. 2012-11-08 18:31:32 +01:00
Erik Dubbelboer
bde06747b8 Added consts keyword where possible 2012-03-30 21:19:51 +02:00
antirez
c0c5a7a6cc sds.c: sdsAllocSize() function added. 2012-03-14 14:58:26 +01:00
antirez
a9004ec1fa 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
80f84859da Obsolete SDS_ABORT_ON_OOM removed from sds.c 2012-01-16 10:08:33 +01:00
antirez
7dbf620812 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
8201022103 Added sdscatsds() to sds.c/h 2011-11-21 15:34:00 +01:00
antirez
7c7125a370 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
09f0a5dfc7 added a comment to sdsMakeRoomFor() to make it clear what the function actually does. 2011-11-02 16:09:14 +01:00
antirez
4153fb8f38 sds.c single quotes support 2011-10-28 17:31:40 +02:00
Pieter Noordhuis
c73a656652 Re-use AOF buffer when it is small enough 2011-09-13 12:22:54 +02:00
antirez
cfd32c162f 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
a95411d5e9 Check seplen and len before malloc'ing "tokens" 2011-05-05 16:32:22 +02:00
Pieter Noordhuis
95fe886c95 Inline sdslen and sdsavail (thanks to @bitbckt) 2011-05-05 16:25:48 +02:00
antirez
c79332ab24 initial cluster config load code 2011-04-07 12:55:02 +02:00
antirez
da14691f5f 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