From a2bec00a9e5fbaf688f32b30fa4b558fbc64462e Mon Sep 17 00:00:00 2001 From: c9s Date: Wed, 28 May 2014 21:02:57 +0800 Subject: [PATCH] match_entry.c --- include/match_entry.h | 19 +++++++++++++++++++ include/r3.h | 5 ----- src/Makefile.am | 2 +- src/match_entry.c | 24 ++++++++++++++++++++++++ src/node.c | 15 --------------- 5 files changed, 44 insertions(+), 21 deletions(-) create mode 100644 include/match_entry.h create mode 100644 src/match_entry.c diff --git a/include/match_entry.h b/include/match_entry.h new file mode 100644 index 0000000..0010dc4 --- /dev/null +++ b/include/match_entry.h @@ -0,0 +1,19 @@ +/* + * match_entry.h + * Copyright (C) 2014 c9s + * + * Distributed under terms of the MIT license. + */ + +#ifndef MATCH_ENTRY_H +#define MATCH_ENTRY_H + +#include "r3.h" + +match_entry * match_entry_createl(const char * path, int path_len); + +#define match_entry_create(path) match_entry_createl(path,strlen(path)) + +void match_entry_free(match_entry * entry); + +#endif /* !MATCH_ENTRY_H */ diff --git a/include/r3.h b/include/r3.h index 207f912..76fe534 100644 --- a/include/r3.h +++ b/include/r3.h @@ -182,11 +182,6 @@ void r3_edge_free(edge * edge); -match_entry * match_entry_createl(const char * path, int path_len); - -#define match_entry_create(path) match_entry_createl(path,strlen(path)) - -void match_entry_free(match_entry * entry); route * r3_route_create(const char * path); diff --git a/src/Makefile.am b/src/Makefile.am index 6616a97..7cd6ae2 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,6 +1,6 @@ lib_LTLIBRARIES = libr3.la # lib_LIBRARIES = libr3.a -libr3_la_SOURCES = node.c edge.c str.c token.c zmalloc.c +libr3_la_SOURCES = node.c edge.c str.c token.c zmalloc.c match_entry.c # libr3_la_LDFLAGS = -export-symbols-regex '^r3_|^match_' libr3_la_LIBADD=$(DEPS_LIBS) diff --git a/src/match_entry.c b/src/match_entry.c new file mode 100644 index 0000000..2396747 --- /dev/null +++ b/src/match_entry.c @@ -0,0 +1,24 @@ +/* + * match_entry.c + * Copyright (C) 2014 c9s + * + * Distributed under terms of the MIT license. + */ +#include "match_entry.h" +#include "zmalloc.h" + +match_entry * match_entry_createl(const char * path, int path_len) { + match_entry * entry = zmalloc(sizeof(match_entry)); + if(!entry) + return NULL; + entry->vars = str_array_create(3); + entry->path = path; + entry->path_len = path_len; + entry->data = NULL; + return entry; +} + +void match_entry_free(match_entry * entry) { + str_array_free(entry->vars); + zfree(entry); +} diff --git a/src/node.c b/src/node.c index 62d0131..a44277b 100644 --- a/src/node.c +++ b/src/node.c @@ -223,21 +223,6 @@ void r3_tree_compile_patterns(node * n) { } -match_entry * match_entry_createl(const char * path, int path_len) { - match_entry * entry = zmalloc(sizeof(match_entry)); - if(!entry) - return NULL; - entry->vars = str_array_create(3); - entry->path = path; - entry->path_len = path_len; - entry->data = NULL; - return entry; -} - -void match_entry_free(match_entry * entry) { - str_array_free(entry->vars); - zfree(entry); -}