Commit Graph

55 Commits

Author SHA1 Message Date
8db3969971 sdsfree x and y 2015-05-04 13:03:06 +02:00
98756d4c0d fix doc example 2015-05-04 13:03:06 +02:00
7316fda33a fix typo 2015-05-04 13:03:06 +02:00
76d53a6770 sds.c: Correct two spelling mistakes in comments 2014-12-09 15:14:14 +01:00
4848cf9335 sds.c/sdscatvprintf: set va_end to finish va_list cpy 2014-12-09 15:14:14 +01:00
d2f584fa53 sds.c: Correct some comments 2014-12-09 15:14:13 +01:00
55597bbd67 Fix on-place -> in-place
Closes #1373
2014-10-06 09:58:18 +02:00
904bd0400c Remove surplus double quotes
Closes #1877
2014-10-06 09:57:01 +02:00
c3eac3ddff No longer useful assert removed from sdsIncrLen(). 2014-08-27 10:31:32 +02:00
134345e332 Use unsigned integers in SDS header.
This raises the max string to 4GB without any downside.
2014-08-27 10:25:54 +02:00
f89a7bbe11 va_copy must be matched by va_end
Hat tip to @rfuchs. See: https://github.com/redis/hiredis/pull/178.

Fixes #1187
2014-08-27 10:25:44 +02:00
60ff8095d6 No more trailing spaces in Redis source code. 2014-06-26 18:52:16 +02:00
95f492ee57 Silence different signs comparison warning in sds.c. 2014-06-23 11:53:50 +02:00
4acc3daa92 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-06-21 15:26:58 +02:00
3a915ace44 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-06-21 15:26:54 +02:00
72257f4b87 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:23:58 +01:00
7a20f09647 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:45:18 +01:00
5e75e681fe comment mistake fixed 2013-12-12 11:25:48 +01:00
7f6743a581 Fixed grammar: before H the article is a, not an. 2013-12-05 16:37:21 +01:00
f899ab55ca 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:22:52 +02:00
57c8e026b9 Every function inside sds.c is now commented. 2013-07-23 16:36:14 +02:00
2150cfebb7 sds.c: new function sdsjoin() to join strings. 2013-07-08 10:25:47 +02:00
f72a3406a7 sds.c: sdssplitargs_free() removed as it was a duplicate. 2013-03-06 12:43:41 +01:00
a70e3ffb16 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:43:32 +01:00
a6f557657c 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:43:27 +01:00
1caf09399e Fixed many typos.
Conflicts fixed, mainly because 2.8 has no cluster support / files:
	00-RELEASENOTES
	src/cluster.c
	src/crc16.c
	src/redis-trib.rb
	src/redis.h
2013-01-19 11:03:19 +01:00
8ddb23b90c BSD license added to every C source and header file. 2012-11-08 18:34:04 +01:00
e04be06e89 Added consts keyword where possible 2012-09-27 13:12:05 +02:00
6934832e53 sds.c: sdsAllocSize() function added. 2012-03-14 15:36:24 +01:00
f9322fb8ed 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 15:36:20 +01:00
1596d6a61e Obsolete SDS_ABORT_ON_OOM removed from sds.c 2012-01-16 10:08:33 +01:00
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
08a879af6e Added sdscatsds() to sds.c/h 2011-11-21 15:34:00 +01:00
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
3526724594 added a comment to sdsMakeRoomFor() to make it clear what the function actually does. 2011-11-02 16:09:14 +01:00
e1cf460cf1 sds.c single quotes support 2011-10-28 17:31:40 +02:00
f990782f4d Re-use AOF buffer when it is small enough 2011-09-13 12:22:54 +02:00
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
c040cbd625 Check seplen and len before malloc'ing "tokens" 2011-05-05 16:32:22 +02:00
ded614f803 Inline sdslen and sdsavail (thanks to @bitbckt) 2011-05-05 16:25:48 +02:00
726a39c15f initial cluster config load code 2011-04-07 12:55:02 +02:00
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
e360e3bb7e Fixed sdssplitargs() handling of hex-style escapes. 2011-03-22 22:49:12 +01:00
612810af6e sdscatrepr() fixed. Now newlines and other special chars are escaped correctly 2011-03-20 18:24:49 +01:00
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
cc20906390 Change function name to match what it does 2010-12-10 12:16:16 +01:00
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
3c1bf4957e Add commands SETBIT/GETBIT 2010-12-09 16:39:33 +01:00
963238f713 more tests for sds.c 2010-09-23 16:39:02 +02:00
136cf53f22 minimal C test framework + a first example sds.c tests 2010-09-23 16:05:17 +02:00