remove memmem
This commit is contained in:
parent
1f895138b1
commit
e9489ec910
28
global.c
28
global.c
|
@ -33,34 +33,6 @@
|
||||||
|
|
||||||
volatile bool button_flag = false;
|
volatile bool button_flag = false;
|
||||||
|
|
||||||
void * memmem(const void *l, size_t l_len, const void *s, size_t s_len)
|
|
||||||
{
|
|
||||||
register char *cur, *last;
|
|
||||||
const char *cl = (const char *)l;
|
|
||||||
const char *cs = (const char *)s;
|
|
||||||
|
|
||||||
/* we need something to compare */
|
|
||||||
if (l_len == 0 || s_len == 0)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
/* "s" must be smaller or equal to "l" */
|
|
||||||
if (l_len < s_len)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
/* special case where s_len == 1 */
|
|
||||||
if (s_len == 1)
|
|
||||||
return memchr(l, (int)*cs, l_len);
|
|
||||||
|
|
||||||
/* the last position where its possible to find "s" in "l" */
|
|
||||||
last = (char *)cl + l_len - s_len;
|
|
||||||
|
|
||||||
for (cur = (char *)cl; cur <= last; cur++)
|
|
||||||
if (cur[0] == cs[0] && memcmp(cur, cs, s_len) == 0)
|
|
||||||
return cur;
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
char* b2s(uint64_t binary, uint8_t rjust)
|
char* b2s(uint64_t binary, uint8_t rjust)
|
||||||
{
|
{
|
||||||
static char string[64+1] = {0}; // the string representation to return
|
static char string[64+1] = {0}; // the string representation to return
|
||||||
|
|
11
global.h
11
global.h
|
@ -127,17 +127,6 @@ extern volatile bool button_flag; /**< flag set when board user button has been
|
||||||
/** default printf output */
|
/** default printf output */
|
||||||
int _write(int file, char *ptr, int len);
|
int _write(int file, char *ptr, int len);
|
||||||
|
|
||||||
|
|
||||||
/** find the first occurrence of the byte string s in byte string l
|
|
||||||
* @copyright 2005 Pascal Gloor <pascal.gloor@spale.com>
|
|
||||||
* @param[in] l byte string to find byte substring in
|
|
||||||
* @param[in] l_len length of l byte string
|
|
||||||
* @param[in] s byte byte substring to find in byte string
|
|
||||||
* @param[in] s_len length of s byte string
|
|
||||||
* @return pointer to the beginning of the substring, or NULL if the substring is not found
|
|
||||||
*/
|
|
||||||
void * memmem(const void *l, size_t l_len, const void *s, size_t s_len);
|
|
||||||
|
|
||||||
/** get binary representation of a number
|
/** get binary representation of a number
|
||||||
* @param[in] binary number to represent in binary
|
* @param[in] binary number to represent in binary
|
||||||
* @param[in] rjust justify representation with leading zeros
|
* @param[in] rjust justify representation with leading zeros
|
||||||
|
|
Loading…
Reference in New Issue