Binary safe string search */
| 80 | |
| 81 | /* Binary safe string search */ |
| 82 | static const char *tpl_strstr(const char *haystack, |
| 83 | ssize_t haystack_len, |
| 84 | const char *needle, |
| 85 | int needle_len) |
| 86 | { |
| 87 | ssize_t i; |
| 88 | const char *p_toofar = haystack + haystack_len - needle_len + 1; |
| 89 | |
| 90 | if (p_toofar <= haystack) |
| 91 | return NULL; |
| 92 | |
| 93 | do |
| 94 | { |
| 95 | if (*haystack == *needle) |
| 96 | { |
| 97 | for (i = 1; i != needle_len && haystack[i] == needle[i]; i++); |
| 98 | |
| 99 | if (i == needle_len) |
| 100 | return haystack; |
| 101 | } |
| 102 | |
| 103 | haystack++; |
| 104 | } |
| 105 | while (haystack != p_toofar); |
| 106 | |
| 107 | return NULL; |
| 108 | } |
| 109 | |
| 110 | |
| 111 | static tpl_node_t* create_node(int len) |
no outgoing calls
no test coverage detected
searching dependent graphs…