mem: add memeqzero. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
mem: Add memswap() function Add a memswap() function to the mem module, which exchanges two (equal sized, non-overlapping) memory regions. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
mem: Add function to check whether memory ranges overlap The test is simple, but every time I do it by hand, I always spend ages convincing myself it's actually correct. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
mem: Remove array_size dependency The mem module declares array_size as a test dependency, and includes it in test/api.c, but doesn't actually use it. This removes the unneeded dependency. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
mem: add memends_str() helper for symmetry Signed-off-by: Cody P Schafer <dev@codyps.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
mem: add mem helper functions Signed-off-by: Cody P Schafer <dev@codyps.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
mem: Implement memrchr() The memrchr() function, which works like memchr(), but searches from the back of the region to the front is implemented in the GNU C library, but isn't standard. This patch adds an implementation of the function to the mem module, when it's not available in the system C library. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
mem: Correct testcases Currently the 'mem' module testcases use test/run.c even though they don't rely on access to the module internals. They're also missing an include of mem.c, which has the effect that on systems with a C library memmem() implementaiton, only that is tested, not the (re-)implementation in the mem module itself. This corrects that by moving run.c to api.c/ Additionally, the memmem() testcases don't cover the case where the "needle" appears multiple times in the "haystack". This patch also adds such a test. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>