summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2012-03-23 15:03:34 +0100
committerYorhel <git@yorhel.nl>2012-03-23 15:03:34 +0100
commitac17e45262dcce1119b610b286ac074f6dd15b0b (patch)
tree4f9730c6a864559aea26a4b5f9ad2ee453192d3c
parent7ba4066c53a94e9051223b0bdf2f1202f90fe29c (diff)
Function name consistency: s/create/new/
-rw-r--r--tanja.c36
-rw-r--r--tanja.h6
-rw-r--r--tanja_pthread.c4
-rw-r--r--test/link.c2
-rw-r--r--test/pthread.c2
5 files changed, 25 insertions, 25 deletions
diff --git a/tanja.c b/tanja.c
index 1d1f4fe..5923ec1 100644
--- a/tanja.c
+++ b/tanja.c
@@ -182,7 +182,7 @@ void tn_tuple_unref(tn_tuple *tup) {
}
-static inline tn_el create_el(char t, va_list va) {
+static inline tn_el el_new(char t, va_list va) {
if(t == TN_VT_AR || t == TN_VT_MAP)
return va_arg(va, tn_el);
tn_el a;
@@ -207,7 +207,7 @@ tn_el tn_array_new(char *lst, ...) {
a.v.a = malloc(a.size*sizeof(tn_el));
int i;
for(i=0; i<a.count; i++)
- a.v.a[i] = create_el(lst[i], va);
+ a.v.a[i] = el_new(lst[i], va);
} else
a.v.a = NULL;
va_end(va);
@@ -235,7 +235,7 @@ void tn_array_append(tn_el *a, char *lst, ...) {
va_start(va, lst);
int i;
for(i=0; i<n; i++)
- a->v.a[a->count++] = create_el(lst[i], va);
+ a->v.a[a->count++] = el_new(lst[i], va);
va_end(va);
}
@@ -251,7 +251,7 @@ tn_el tn_map_new(char *lst, ...) {
int i;
for(i=0; i<a.count; i++) {
a.v.m[i].key = va_arg(va, char *);
- a.v.m[i].val = create_el(lst[i], va);
+ a.v.m[i].val = el_new(lst[i], va);
}
} else
a.v.m = NULL;
@@ -283,7 +283,7 @@ void tn_map_set(tn_el *m, char *lst, ...) {
int i;
for(i=0; i<n; i++) {
m->v.m[m->count].key = va_arg(va, char *);
- m->v.m[m->count].val = create_el(lst[i], va);
+ m->v.m[m->count].val = el_new(lst[i], va);
m->count++;
}
va_end(va);
@@ -298,7 +298,7 @@ tn_tuple *tn_tuple_new(char *lst, ...) {
va_start(va, lst);
int i;
for(i=0; i<t->n; i++)
- t->e[i] = create_el(lst[i], va);
+ t->e[i] = el_new(lst[i], va);
va_end(va);
return t;
}
@@ -864,7 +864,7 @@ static inline void tn_returnpath_open(tn_returnpath *rp) {
}
-static inline tn_returnpath *tn_returnpath_create_ses(tn_session *ses, tn_reply_cb cb, void *dat) {
+static inline tn_returnpath *tn_returnpath_new_ses(tn_session *ses, tn_reply_cb cb, void *dat) {
tn_returnpath *rp = malloc(sizeof(tn_returnpath));
rp->ref = 0; // No senders yet
rp->type = 0;
@@ -876,7 +876,7 @@ static inline tn_returnpath *tn_returnpath_create_ses(tn_session *ses, tn_reply_
}
-static inline tn_returnpath *tn_returnpath_create_link(tn_link *l, int tid) {
+static inline tn_returnpath *tn_returnpath_new_link(tn_link *l, int tid) {
tn_returnpath *rp = malloc(sizeof(tn_returnpath));
rp->ref = 0; // No senders yet
rp->type = 1;
@@ -916,7 +916,7 @@ struct patternreg {
};
-static inline patternreg *patternreg_create_ses(tn_tuple *pat, int willreply, tn_session *ses, tn_tuple_cb cb, void *dat) {
+static inline patternreg *patternreg_new_ses(tn_tuple *pat, int willreply, tn_session *ses, tn_tuple_cb cb, void *dat) {
patternreg *r = malloc(sizeof(patternreg));
r->ref = 1;
r->active = 1;
@@ -930,7 +930,7 @@ static inline patternreg *patternreg_create_ses(tn_tuple *pat, int willreply, tn
}
-static inline patternreg *patternreg_create_link(tn_tuple *pat, tn_link *l) {
+static inline patternreg *patternreg_new_link(tn_tuple *pat, tn_link *l) {
patternreg *r = malloc(sizeof(patternreg));
r->ref = 1;
r->active = 1;
@@ -972,7 +972,7 @@ struct tn_node {
};
-tn_node *tn_node_create() {
+tn_node *tn_node_new() {
tn_node *n = malloc(sizeof(tn_node));
mutex_init(n->lock);
n->regs = kh_init(pr);
@@ -1136,7 +1136,7 @@ void tn_session_unref(tn_session *s) {
}
-tn_session *tn_session_create(tn_node *n, tn_session_dispatch_cb dis, void *data) {
+tn_session *tn_session_new(tn_node *n, tn_session_dispatch_cb dis, void *data) {
assert(dis);
assert(n);
tn_session *s = malloc(sizeof(tn_session));
@@ -1155,7 +1155,7 @@ tn_session *tn_session_create(tn_node *n, tn_session_dispatch_cb dis, void *data
void tn_session_send(tn_session *s, tn_tuple *t, tn_reply_cb cb, void *dat) {
assert(s);
assert(t);
- tn_node_send(s->node, t, cb ? tn_returnpath_create_ses(s, cb, dat) : NULL, NULL);
+ tn_node_send(s->node, t, cb ? tn_returnpath_new_ses(s, cb, dat) : NULL, NULL);
}
@@ -1164,7 +1164,7 @@ int tn_session_register(tn_session *s, tn_tuple *pat, int willreply, tn_tuple_cb
assert(pat);
assert(cb);
mutex_lock(s->node->lock);
- int id = tn_node_register(s->node, patternreg_create_ses(pat, willreply, s, cb, dat));
+ int id = tn_node_register(s->node, patternreg_new_ses(pat, willreply, s, cb, dat));
mutex_unlock(s->node->lock);
return id;
}
@@ -1356,7 +1356,7 @@ void tn_link_unref(tn_link *l) {
// TODO: configure a maximum buffer size?
-tn_link *tn_link_create(tn_node *n, tn_link_context *ctx, void *data) {
+tn_link *tn_link_new(tn_node *n, tn_link_context *ctx, void *data) {
tn_link *l = malloc(sizeof(tn_link));
l->node = n;
l->ctx = ctx;
@@ -1694,7 +1694,7 @@ static inline void tn_link_handlehandshake(tn_link *l, const char *buf, int len)
} else {
mutex_lock(l->node->lock);
mutex_lock(l->lock);
- l->catchall = tn_node_register(l->node, patternreg_create_link(tn_tuple_new(""), l));
+ l->catchall = tn_node_register(l->node, patternreg_new_link(tn_tuple_new(""), l));
mutex_unlock(l->lock);
mutex_unlock(l->node->lock);
l->synced = 1;
@@ -1841,7 +1841,7 @@ static void tn_link_handlemessage(tn_link *l, int type, int32_t arg, tn_tuple *t
mutex_lock(l->node->lock);
mutex_lock(l->lock);
if(l->active) {
- int id = tn_node_register(l->node, patternreg_create_link(tup, l));
+ int id = tn_node_register(l->node, patternreg_new_link(tup, l));
khiter_t k = kh_get(ii, l->regs, arg);
if(k != kh_end(l->regs))
tn_node_unregister(l->node, kh_val(l->regs, k));
@@ -1877,7 +1877,7 @@ static void tn_link_handlemessage(tn_link *l, int type, int32_t arg, tn_tuple *t
break;
case 5: // tuple tid tuple
- tn_node_send(l->node, tup, arg > 0 ? tn_returnpath_create_link(l, arg) : NULL, l);
+ tn_node_send(l->node, tup, arg > 0 ? tn_returnpath_new_link(l, arg) : NULL, l);
break;
case 6: { // reply tid tuple
diff --git a/tanja.h b/tanja.h
index 0d8b3e2..f00d76b 100644
--- a/tanja.h
+++ b/tanja.h
@@ -109,11 +109,11 @@ tn_tuple *tn_json_parse(const char *, int, int *);
void tn_reply(tn_returnpath *, tn_tuple *);
void tn_reply_close(tn_returnpath *rp);
-tn_node *tn_node_create();
+tn_node *tn_node_new();
void tn_node_ref(tn_node *);
void tn_node_unref(tn_node *);
-tn_session *tn_session_create(tn_node *, tn_session_dispatch_cb, void *);
+tn_session *tn_session_new(tn_node *, tn_session_dispatch_cb, void *);
void tn_session_ref(tn_session *);
void tn_session_unref(tn_session *);
void tn_session_send(tn_session *, tn_tuple *, tn_reply_cb, void *dat);
@@ -122,7 +122,7 @@ void tn_session_unregister(tn_session *, int);
int tn_session_dispatch(tn_session *);
void tn_session_close(tn_session *);
-tn_link *tn_link_create(tn_node *, tn_link_context *, void *);
+tn_link *tn_link_new(tn_node *, tn_link_context *, void *);
void tn_link_ref(tn_link *);
void tn_link_unref(tn_link *);
void tn_link_on_error(tn_link *, tn_link_error_cb);
diff --git a/tanja_pthread.c b/tanja_pthread.c
index baff622..e0a6d0b 100644
--- a/tanja_pthread.c
+++ b/tanja_pthread.c
@@ -100,7 +100,7 @@ tn_session *tn_session_pthread(tn_node *n, pthread_t *t) {
return NULL;
pt_sdat *dat = malloc(sizeof(pt_sdat));
- dat->s = tn_session_create(n, sdispatch, dat);
+ dat->s = tn_session_new(n, sdispatch, dat);
tn_session_ref(dat->s);
if(pthread_create(&(dat->self), NULL, sthread, dat) < 0) {
tn_session_unref(dat->s);
@@ -226,7 +226,7 @@ tn_link *tn_link_pthread_fd(tn_node *n, int fdin, int fdout, pthread_t *t) {
pt_fdldat *dat = malloc(sizeof(pt_fdldat));
dat->fdin = fdin;
dat->fdout = fdout;
- dat->l = tn_link_create(n, &ctx, dat);
+ dat->l = tn_link_new(n, &ctx, dat);
tn_link_ref(dat->l);
if(pthread_create(&dat->self, NULL, fdlthread, dat) < 0) {
tn_link_unref(dat->l);
diff --git a/test/link.c b/test/link.c
index 8ce964d..178278a 100644
--- a/test/link.c
+++ b/test/link.c
@@ -119,7 +119,7 @@ static void lnk_ready(tn_link *l) {
int main() {
- tn_node *n = tn_node_create();
+ tn_node *n = tn_node_new();
// Create a session for debugging
pthread_t tha;
diff --git a/test/pthread.c b/test/pthread.c
index 8c50e6c..0c91c57 100644
--- a/test/pthread.c
+++ b/test/pthread.c
@@ -118,7 +118,7 @@ static void recv_reply(tn_session *s, tn_tuple *tup, void *d) {
int main() {
- tn_node *n = tn_node_create();
+ tn_node *n = tn_node_new();
t_assert(n != NULL);
// Create session a