1d4e5de8414ed93d1c810b30a91ad83d6d954861 |
|
15-Dec-2017 |
Sergey Kitov <sergey.kitov@open-xchange.com> |
lib: array_idx_modifiable changed not to allocate space. |
0fd9c892b5012536bd674fb153cdae8c5e0fc17a |
|
15-Dec-2017 |
Sergey Kitov <sergey.kitov@open-xchange.com> |
lib: array_idx_get_space is defined as alias to array_idx_modifiable |
19557f192d37cd54a1a090a8a26d9d47265e4413 |
|
01-Nov-2017 |
Aki Tuomi <aki.tuomi@dovecot.fi> |
global: Fix spelling mistakes in comments
Original work by @andreasschulze and @jsoref |
2d729323913a672708dc600242e1cc3085985dcc |
|
19-Apr-2016 |
Phil Carmody <phil@dovecot.fi> |
lib: array - new copy-making array iterator
Previously macros took a pointer, and that pointer was made to pointed
to each element of the array in turn. Typical use cases for things like
char* or struct* arrays were to immediately/repeatedly, dereference that
pointer.
This new iter (only one implementation done so far, more a proof of
concept) gets rid of the user-visable pointer, and performs the
dereference every time, and only when, a valid element is being
iterated over. Empty array => no assignment. No U.B.
NOTE: This cannot be done without assuming C99. It breaks the build
on compilers that old if any components that are enabled use the
macro. It strongly suggests we just need to make C99 mandatory.
Signed-off-by: Phil Carmody <phil@dovecot.fi> |
fdc468280e23ddd3a91a0539e7a48ba9c8a60d27 |
|
15-Jun-2015 |
Phil Carmody <phil@dovecot.fi> |
lib: array - permit array_swap with uninitialised arrays
Before initialisation, all fields are blank, so the element_size field
is not the actual size, and the i_assert would fire.
Signed-off-by: Phil Carmody <phil@dovecot.fi> |
fbb70476f061c614bc7a99889e76f988d1cf4019 |
|
02-Feb-2015 |
Phil Carmody <phil@dovecot.fi> |
lib: array - two helpers to avoid wasteful array_count
There's no need to dereference array->element_size and
perform a division when all you care about is the boolean
isempty/nonempty predicate:
$ git grep 'array_count(.*) > 0' | wc -l
77
$ git grep 'array_count(.*) == 0' | wc -l
95
Changing 6 of them has the following impact on the code:
$ size src/lib-imap-client/imapc-connection.o
text data bss dec hex filename
20879 0 4 20883 5193 src/lib-imap-client/imapc-connection.o
$ size src/lib-imap-client/imapc-connection.o
text data bss dec hex filename
20796 0 4 20800 5140 src/lib-imap-client/imapc-connection.o
Signed-off-by: Phil Carmody <phil@dovecot.fi> |
9a6250aecfe56f0970761806c16794c04330f46a |
|
24-Jan-2015 |
Phil Carmody <phil@dovecot.fi> |
lib: array - helper to swap array buffer ownership
Currently there's no simple way to create a replacement for an array,
and then atomically switch in that replacement. With this helper,
you can just exchange ownership of the two lists and then free the
new list (which now contains the old buffer).
Signed-off-by: Phil Carmody <phil@dovecot.fi> |
fe08c73b0bf87bfa3bfb2d3df5dc9845113e0cf3 |
|
05-Jan-2015 |
Phil Carmody <phil@dovecot.fi> |
lib: array - explain implications of ARRAY_TYPE() in comment
If you use ARRAY_TYPE() to pass an array around, then you must also
use ARRAY_TYPE() to define the array itself, ARRAY() will no longer do.
Reported-by: Arnt Gulbrandsen <arnt@gulbrandsen.priv.no>
Signed-off-by: Phil Carmody <phil@dovecot.fi> |
c029156a6eed53d440b496406e3df08b569568ec |
|
05-Jan-2015 |
Phil Carmody <phil@dovecot.fi> |
lib: array - new linear search helper
There are large numbers of array_foreach loops which do nothing but search
for the first element which matches some key. This can be abstracted out
into a helper.
Signed-off-by: Phil Carmody <phil@dovecot.fi> |
842f5a5ebfbb6f9a550fd4fa5cf9ef963943d82f |
|
28-Nov-2014 |
Phil Carmody <phil@dovecot.fi> |
lib: array - array_foreach_idx is just a generic ptr_to_idx helper
Signed-off-by: Phil Carmody <phil@dovecot.fi> |
173b12537fdc65f71235073193223e811a00d130 |
|
28-Nov-2014 |
Phil Carmody <phil@dovecot.fi> |
lib: test-array - remove possibility to optimise out tests
(void) on a call to a "pure" function was causing some compilers (gcc 4.8)
to not reach the assert within the pure function. Technically it's not a
pure function, as (in the assert fail case) it has effects other than its
return value. However, simply removing the void cast (and then actually
using the return value) also prevents this optimisation.
An additional fatal test was added - there's a difference between an access
outside the allocated range and outside the initialised range.
Signed-off-by: Phil Carmody <phil@dovecot.fi> |
70c380a7b077e7c9fab056d977f0415bf8d063e0 |
|
25-Nov-2014 |
Phil Carmody <phil@dovecot.fi> |
lib: array - additional compile-time checks to array_append
The new two-array helper macro works in this context too.
Note: array_copy doesn't have any protection currently, it isn't
obvious how to wrap that with some safety without breaking interfaces.
It only seems to have one internal user, lib/aqueue.
Signed-off-by: Phil Carmody <phil@dovecot.fi> |
0f111ddfcb893d75a79bb60942c77d97e15f6b99 |
|
25-Nov-2014 |
Phil Carmody <phil@dovecot.fi> |
lib: array - element-wise comparison via callback
2 are provided - with and without a context pointer.
Signed-off-by: Phil Carmody <phil@dovecot.fi> |
887e05e03f83735acd5479be563193b3c2584d91 |
|
14-Nov-2014 |
Phil Carmody <phil@dovecot.fi> |
lib: array/hash - enable typof checks for more compilers
We have a HAVE_TYPEOF macro from autoconf, we may as well make use of it.
Signed-off-by: Phil Carmody <phil@dovecot.fi> |
fcb19f9e9933ef693fe98d3925ea52887ea8cd86 |
|
14-Nov-2014 |
Phil Carmody <phil@dovecot.fi> |
lib: array/hash - protect macro parameters
If a pointer parameter p is ``ptr + offset'', then sizeof(*p) becomes
sizeof(*ptr + offset), which isn't what was wanted. sizeof(*(p)) is the
safe expression to use instead. Ditto for just ``*data'' in array.h.
The macros in hash.h which have been changed have been reindented for
better readability and consistency.
The bracketting of elem in (elem)++ in both of the array_foreach* macros
isn't actually useful, as elem participates in token-pasting elsewhere.
However, the two macros have been made more similar to each other for
better parallelism.
Signed-off-by: Phil Carmody <phil@dovecot.fi> |
27a44fcfd8d19bffe0f267f20a2b5d3fe7600fdd |
|
19-Aug-2012 |
Timo Sirainen <tss@iki.fi> |
Removed CONTEXT_TYPE_SAFETY macro and reimplemented its functionality better.
gcc/clang now gives a compiler error in many places if callback isn't
exactly what was expected. It's also now much easier to add more of these
checks. |
4ee00532a265bdfb38539d811fcd12d51210ac35 |
|
19-Aug-2012 |
Timo Sirainen <tss@iki.fi> |
Array API changed: ARRAY_DEFINE(name, type) -> ARRAY(type) name
Easy way to update your existing code:
perl -i -pe 's:ARRAY_DEFINE\(([^,]+), *([^)]+)\);:ARRAY($2) $1;:' **/*.[ch] |
31a574fda352ef4f71dbff9c30e15e4744e132c0 |
|
25-Jun-2012 |
Timo Sirainen <tss@iki.fi> |
Added array_append_zero() to write a zero-filled record to an array.
Replaced (void)array_append_space() calls with it. |
0f819b4ecd3a144514f576516177029ffe0bd6d5 |
|
28-Apr-2012 |
Timo Sirainen <tss@iki.fi> |
Code cleanup: Use array_count_i() to calculate array's size internally. |
d429602cea56ee72e75b9f0fea372009efc25736 |
|
02-Dec-2009 |
Timo Sirainen <tss@iki.fi> |
Added array_foreach_idx()
--HG--
branch : HEAD |
e254755d9daaf6b1503798f1bf1d9376d4197d6a |
|
14-Nov-2009 |
Timo Sirainen <tss@iki.fi> |
array_bsearch(): Cast return value to proper type.
--HG--
branch : HEAD |
548bf569f620a42a34dcddd95260d7da587b230e |
|
05-Nov-2009 |
Timo Sirainen <tss@iki.fi> |
array_foreach_modifiable() was broken in non-C99 compilers.
Patch by Apple.
--HG--
branch : HEAD |
f9c84eed1019d750da00a73d904584e77762a416 |
|
27-Oct-2009 |
Timo Sirainen <tss@iki.fi> |
array.h: Compile fix for non-C99 compilers.
--HG--
branch : HEAD |
1df7543b209cabc208515c6bfc3b123f6ea184c2 |
|
08-Oct-2009 |
Timo Sirainen <tss@iki.fi> |
Added array_foreach() and array_foreach_modifiable().
--HG--
branch : HEAD |
40252a7eb6030f51dc6436e5b844c8a65890a736 |
|
10-Jul-2009 |
Timo Sirainen <tss@iki.fi> |
Added type safe array_bsearch().
--HG--
branch : HEAD |
304cda7b78964aeacda7cd5388c7eb2a0be3e31a |
|
17-Jun-2009 |
Timo Sirainen <tss@iki.fi> |
Added array_sort() for type-safe array sorting.
--HG--
branch : HEAD |
3e414ac92b8ae252489d13c34730507898cdcfb9 |
|
10-Jan-2009 |
Timo Sirainen <tss@iki.fi> |
Added array_get_pool().
Patch by Stephan Bosch.
--HG--
branch : HEAD |
704c2286d31146b8ab5bf908ef7d66d79917db2a |
|
01-Sep-2008 |
Timo Sirainen <tss@iki.fi> |
array_copy() was broken if source array was different from destination array.
--HG--
branch : HEAD |
68a4946b12583b88fa802e52ebee45cd96056772 |
|
20-Jun-2008 |
Timo Sirainen <tss@iki.fi> |
Added more consts, ATTR_CONSTs and ATTR_PUREs.
--HG--
branch : HEAD |
7c7bf95aba9c99e31eb2a3b4732b6a765f774436 |
|
13-Jun-2008 |
Timo Sirainen <tss@iki.fi> |
Added array_reverse().
--HG--
branch : HEAD |
aa181b6e3751d4e76da6f135729032660b14406c |
|
13-Jun-2008 |
Timo Sirainen <tss@iki.fi> |
Uninlined some of the more complex array functions.
--HG--
branch : HEAD |
f59e2b09deeb94317342016949592577ef150c1b |
|
29-Dec-2007 |
Timo Sirainen <tss@iki.fi> |
Added queue implementation.
--HG--
branch : HEAD |
684844265f01abd1da5864647a6dd69cc1bbbc71 |
|
15-Sep-2007 |
Timo Sirainen <tss@iki.fi> |
Renamed _array_*() to array_*_i()
--HG--
branch : HEAD |
0f66f12eb4cdbf47670975044c88d8f388bf92df |
|
15-Sep-2007 |
Timo Sirainen <tss@iki.fi> |
Changed buffer_free() and buffer_free_without_data() APIs to take ** pointer
which is set to NULL instead of hiding it with a macro.
--HG--
branch : HEAD |
c25356d5978632df6203437e1953bcb29e0c736f |
|
16-Sep-2007 |
Timo Sirainen <tss@iki.fi> |
Changed .h ifdef/defines to use <NAME>_H format.
--HG--
branch : HEAD |
b046ca519fc1092495691df7256de32a18dc7a17 |
|
31-Mar-2007 |
Timo Sirainen <tss@iki.fi> |
Use COMPILE_ERROR_IF_TYPES_NOT_COMPATIBLE() for validating the data type.
--HG--
branch : HEAD |
9c43710d352b6c1f03ec3c7790b752c87be32149 |
|
25-Jan-2007 |
Timo Sirainen <tss@iki.fi> |
Removed disable-asserts-specific array_idx(). It didn't work if array's
element_size was different than sizeof(element type).
--HG--
branch : HEAD |
11a29a16c8b41ad7c057420e53963a4595adc33d |
|
15-Nov-2006 |
Timo Sirainen <tss@iki.fi> |
Removed extra ';'
--HG--
branch : HEAD |
c6eca51b54586c1f37cfe39e38c844da3f937a4d |
|
16-Sep-2006 |
Timo Sirainen <tss@iki.fi> |
Don't allow giving NULL parameter to array_get() or array_get_modifiable().
--HG--
branch : HEAD |
c848d8976d0a5e92a406d0e4a9f0b6f46d9eefd8 |
|
16-Sep-2006 |
Timo Sirainen <tss@iki.fi> |
Some more array changes. v and v_modifiable are now pointer-to-pointers so
that they can actually be used to access the array's contents directly. Only
array_idx() uses this currently though, and only if asserts are disabled.
--HG--
branch : HEAD |
91dca97b367c54a139c268b56a0c67f564bd9197 |
|
10-Sep-2006 |
Timo Sirainen <tss@iki.fi> |
Replaced ARRAY_CREATE() macro with [ipt]_array_init() macros. The macro
has no side effects so it might as well be lowercased.
--HG--
branch : HEAD |
26a8b7deb3a5b6f26f9c4d71538e1248f680e4be |
|
10-Sep-2006 |
Timo Sirainen <tss@iki.fi> |
Removed type parameter from ARRAY_CREATE since it's not needed anymore.
--HG--
branch : HEAD |
489a4b34972902602320f910fc0c6014ea072c50 |
|
28-Jun-2006 |
Timo Sirainen <timo.sirainen@movial.fi> |
Added array_idx_clear().
--HG--
branch : HEAD |
8d80659e504ffb34bb0c6a633184fece35751b18 |
|
28-Jun-2006 |
Timo Sirainen <tss@iki.fi> |
Array API redesigned to work using unions. It now provides type safety
without having to enable DEBUG, as long as the compiler supports typeof().
Its API changed a bit. It now allows directly accessing the array contents,
although that's not necessarily recommended. Changed existing array usage to
be type safe in a bit more places. Removed array_t completely. Also did
s/modifyable/modifiable/.
--HG--
branch : HEAD |
6ef7e31619edfaa17ed044b45861d106a86191ef |
|
13-Jan-2006 |
Timo Sirainen <tss@iki.fi> |
Added "bool" type and changed all ints that were used as booleans to bool.
--HG--
branch : HEAD |
16f816d3f3c32ae3351834253f52ddd0212bcbf3 |
|
04-Jul-2005 |
Timo Sirainen <tss@iki.fi> |
Moved array declaration to array-decl.h and include it in lib.h. So array.h
needs to be now included to use any array_*() functions.
--HG--
branch : HEAD |
053843989f13d9013b265fb401a4bde7e0e6568e |
|
28-Jun-2005 |
Timo Sirainen <tss@iki.fi> |
Renamed array_modifyable_*() functions. I could never remember how they were
named.
--HG--
branch : HEAD |
2a7666fd3168ba04c4c027391cdddf0b7fc8074b |
|
26-Apr-2005 |
Timo Sirainen <tss@iki.fi> |
Still more changes to how typeof() is used. Now it finally seems to be
working nicely.
--HG--
branch : HEAD |
954dc3045a1df5594a1a7a0bc212ad4a92d62a20 |
|
10-Apr-2005 |
Timo Sirainen <tss@iki.fi> |
ARRAY_CREATE() macro fix. Wasn't working in all situations.
--HG--
branch : HEAD |
b2d3ce601222d42ac334ee8d38f6aabdace83729 |
|
08-Apr-2005 |
Timo Sirainen <tss@iki.fi> |
Added ARRAY_DEFINE_EXTERN().
--HG--
branch : HEAD |
bb10ebcf076c959c752f583746d83805d7686df8 |
|
02-Apr-2005 |
Timo Sirainen <tss@iki.fi> |
Keywords are now stored in X-Keywords headers in mbox. Did several related
API changes to get better performance.
--HG--
branch : HEAD |
67d0d392020205daa85c5b109ab82d266eb6eefb |
|
02-Apr-2005 |
Timo Sirainen <tss@iki.fi> |
Added ARRAY_DEFINE_PTR() which needs to be used instead of ARRAY_DEFINE()
for pointers.
--HG--
branch : HEAD |
0bed9236fca9b177d4bc3b4663e938097a73bab2 |
|
18-Mar-2005 |
Timo Sirainen <tss@iki.fi> |
ARRAY_SET_TYPE() in non-DEBUG-mode was giving errors with older gccs if it
was used at the beginning of a function (function can't start with ";").
--HG--
branch : HEAD |
7cc4505269e2ead2530f8de14ec0fdb626c61793 |
|
15-Mar-2005 |
Timo Sirainen <tss@iki.fi> |
Added ARRAY_INIT for initializing array_t in structs.
--HG--
branch : HEAD |
7c8d2127479db2f10e434af218d29a21b86132e9 |
|
12-Mar-2005 |
Timo Sirainen <tss@iki.fi> |
#ifdefs were wrong, we need both __GNUC__ and DEBUG to do type checking.
Added new ARRAY_TYPE_CHECKS macro which can also be defined manually to
enable it.
--HG--
branch : HEAD |
3bc4e3b9f4ce6c3e771fa5ba284daa42828a9ce6 |
|
12-Mar-2005 |
Timo Sirainen <tss@iki.fi> |
Renamed ARRAY_ARG_SET_TYPE() to ARRAY_SET_TYPE() and updated comments.
--HG--
branch : HEAD |
bd3714d623d67f7dc8bd70ba39b467762ae409e8 |
|
12-Mar-2005 |
Timo Sirainen <tss@iki.fi> |
Updated example code, it was using older API..
--HG--
branch : HEAD |
30972f343b285b6214ea053e1939b92cfe79040c |
|
12-Mar-2005 |
Timo Sirainen <tss@iki.fi> |
Added dynamic array implementation. When compiling with gcc and DEBUG
enabled, gcc checks type safety at compile time.
--HG--
branch : HEAD |