| 4994 | agent_history_mark mark) { |
| 4995 | if (p->len == p->cap) { |
| 4996 | p->cap = p->cap ? p->cap * 2 : 16; |
| 4997 | p->v = xrealloc(p->v, (size_t)p->cap * sizeof(p->v[0])); |
| 4998 | p->mark = xrealloc(p->mark, (size_t)p->cap * sizeof(p->mark[0])); |
| 4999 | } |
| 5000 | p->v[p->len] = s; |
| 5001 | p->mark[p->len] = mark; |
| 5002 | p->len++; |
| 5003 | } |
| 5004 | |
| 5005 | static const char *agent_memmem(const char *hay, size_t hay_len, |
| 5006 | const char *needle, size_t needle_len) { |
| 5007 | if (!needle_len) return hay; |
| 5008 | if (needle_len > hay_len) return NULL; |
| 5009 | const char first = needle[0]; |
| 5010 | const char *end = hay + hay_len - needle_len + 1; |
no test coverage detected