#include "config.h"
#endif
+#include <lib-lib/mem.h>
+#include <lib-lib/str.h>
+
#include "rx.h"
-#include "mem.h"
-#include "str.h"
rx_t *rx_compile (const char *s, int flags) {
- rx_t *pp = safe_calloc (1, sizeof (rx_t));
+ rx_t *pp = p_new(rx_t, 1);
- pp->pattern = safe_strdup (s);
- pp->rx = safe_calloc (1, sizeof (regex_t));
+ pp->pattern = m_strdup(s);
+ pp->rx = p_new(regex_t, 1);
if (REGCOMP(pp->rx, NONULL (s), flags) != 0)
rx_free (&pp);
}
void rx_free (rx_t** p) {
- FREE(&(*p)->pattern);
+ p_delete(&(*p)->pattern);
regfree ((*p)->rx);
- FREE(&(*p)->rx);
- FREE(p);
+ p_delete(&(*p)->rx);
+ p_delete(p);
}
int rx_compare (const rx_t* r1, const rx_t* r2) {
- return (safe_strcmp (r1->pattern, r2->pattern));
+ return (m_strcmp(r1->pattern, r2->pattern));
}
int rx_list_match (list2_t* l, const char* pat) {
if (!pat || !*pat || list_empty(l))
return (-1);
for (i = 0; i < l->length; i++)
- if (safe_strcmp (((rx_t*) l->data[i])->pattern, pat) == 0)
+ if (m_strcmp(((rx_t*) l->data[i])->pattern, pat) == 0)
return (i);
return (-1);
}