kore

Kore is a web application platform for writing scalable, concurrent web based processes in C or Python.
Commits | Files | Refs | README | LICENSE | git clone https://git.kore.io/kore.git

commit 9c7aaf179fbb1be3cd467340730d6bb418cd4662
parent 94737a2a5f52d805cad9e36bf8bf5debbcaebb8b
Author: Joris Vink <joris@coders.se>
Date:   Sat, 13 Jul 2013 21:08:55 +0200

Remove unneeded malloc result casting, annoying habbit of mine but serves no purpose.

Diffstat:
src/buf.c | 6+++---
src/connection.c | 3++-
src/domain.c | 2+-
src/http.c | 14+++++++-------
src/mem.c | 2+-
src/module.c | 2+-
src/net.c | 10+++++-----
src/spdy.c | 15+++++++--------
src/utils.c | 2+-
9 files changed, 28 insertions(+), 28 deletions(-)

diff --git a/src/buf.c b/src/buf.c @@ -21,8 +21,8 @@ kore_buf_create(u_int32_t initial) { struct kore_buf *buf; - buf = (struct kore_buf *)kore_malloc(sizeof(*buf)); - buf->data = (u_int8_t *)kore_malloc(initial); + buf = kore_malloc(sizeof(*buf)); + buf->data = kore_malloc(initial); buf->length = initial; buf->offset = 0; @@ -34,7 +34,7 @@ kore_buf_append(struct kore_buf *buf, u_int8_t *d, u_int32_t len) { if ((buf->offset + len) >= buf->length) { buf->length += len + KORE_BUF_INCREMENT; - buf->data = (u_int8_t *)kore_realloc(buf->data, buf->length); + buf->data = kore_realloc(buf->data, buf->length); } memcpy((buf->data + buf->offset), d, len); diff --git a/src/connection.c b/src/connection.c @@ -32,7 +32,8 @@ kore_connection_accept(struct listener *l, struct connection **out) *out = NULL; len = sizeof(struct sockaddr_in); - c = (struct connection *)kore_malloc(sizeof(*c)); + + c = kore_malloc(sizeof(*c)); if ((c->fd = accept(l->fd, (struct sockaddr *)&(c->sin), &len)) == -1) { kore_mem_free(c); kore_debug("accept(): %s", errno_s); diff --git a/src/domain.c b/src/domain.c @@ -35,7 +35,7 @@ kore_domain_new(char *domain) kore_debug("kore_domain_new(%s)", domain); - dom = (struct kore_domain *)kore_malloc(sizeof(*dom)); + dom = kore_malloc(sizeof(*dom)); dom->accesslog = -1; dom->certfile = NULL; dom->certkey = NULL; diff --git a/src/http.c b/src/http.c @@ -48,7 +48,7 @@ http_request_new(struct connection *c, struct spdy_stream *s, char *host, if (strlen(path) >= HTTP_URI_LEN - 1) return (KORE_RESULT_ERROR); - req = (struct http_request *)kore_malloc(sizeof(*req)); + req = kore_malloc(sizeof(*req)); req->end = 0; req->start = 0; req->flags = 0; @@ -152,7 +152,7 @@ http_response_header_add(struct http_request *req, char *header, char *value) kore_debug("http_response_header_add(%p, %s, %s)", req, header, value); - hdr = (struct http_header *)kore_malloc(sizeof(*hdr)); + hdr = kore_malloc(sizeof(*hdr)); hdr->header = kore_strdup(header); hdr->value = kore_strdup(value); TAILQ_INSERT_TAIL(&(req->resp_headers), hdr, list); @@ -280,7 +280,7 @@ http_request_header_get(struct http_request *req, char *header, char **out) TAILQ_FOREACH(hdr, &(req->req_headers), list) { if (!strcasecmp(hdr->header, header)) { r = strlen(hdr->value) + 1; - *out = (char *)kore_malloc(r); + *out = kore_malloc(r); kore_strlcpy(*out, hdr->value, r); return (KORE_RESULT_OK); } @@ -320,7 +320,7 @@ http_header_recv(struct netbuf *nb) end_headers += 2; len = end_headers - nb->buf; - hbuf = (char *)kore_malloc(len + 1); + hbuf = kore_malloc(len + 1); kore_strlcpy(hbuf, (char *)nb->buf, len + 1); h = kore_split_string(hbuf, "\r\n", headers, HTTP_REQ_HEADER_MAX); @@ -387,7 +387,7 @@ http_header_recv(struct netbuf *nb) *(p++) = '\0'; if (*p == ' ') p++; - hdr = (struct http_header *)kore_malloc(sizeof(*hdr)); + hdr = kore_malloc(sizeof(*hdr)); hdr->header = kore_strdup(headers[i]); hdr->value = kore_strdup(p); TAILQ_INSERT_TAIL(&(req->req_headers), hdr, list); @@ -459,7 +459,7 @@ http_populate_arguments(struct http_request *req) continue; } - q = (struct http_arg *)kore_malloc(sizeof(*q)); + q = kore_malloc(sizeof(*q)); q->name = kore_strdup(val[0]); if (c == 2) q->value = kore_strdup(val[1]); @@ -500,7 +500,7 @@ http_post_data_text(struct http_request *req) data = kore_buf_release(req->post_data, &len); len++; - text = (char *)kore_malloc(len); + text = kore_malloc(len); kore_strlcpy(text, (char *)data, len); kore_mem_free(data); diff --git a/src/mem.c b/src/mem.c @@ -112,7 +112,7 @@ kore_strdup(const char *str) char *nstr; len = strlen(str) + 1; - nstr = (char *)kore_malloc(len); + nstr = kore_malloc(len); kore_strlcpy(nstr, str, len); return (nstr); diff --git a/src/module.c b/src/module.c @@ -113,7 +113,7 @@ kore_module_handler_new(char *path, char *domain, char *func, int type) if ((dom = kore_domain_lookup(domain)) == NULL) return (KORE_RESULT_ERROR); - hdlr = (struct kore_module_handle *)kore_malloc(sizeof(*hdlr)); + hdlr = kore_malloc(sizeof(*hdlr)); hdlr->errors = 0; hdlr->addr = addr; hdlr->type = type; diff --git a/src/net.c b/src/net.c @@ -24,7 +24,7 @@ net_send_queue(struct connection *c, u_int8_t *data, size_t len, int flags, //kore_debug("net_send_queue(%p, %p, %d, %p)", c, data, len, cb); - nb = (struct netbuf *)kore_malloc(sizeof(*nb)); + nb = kore_malloc(sizeof(*nb)); nb->cb = cb; nb->len = len; nb->owner = c; @@ -33,7 +33,7 @@ net_send_queue(struct connection *c, u_int8_t *data, size_t len, int flags, nb->type = NETBUF_SEND; if (len > 0) { - nb->buf = (u_int8_t *)kore_malloc(nb->len); + nb->buf = kore_malloc(nb->len); memcpy(nb->buf, data, nb->len); } else { nb->buf = NULL; @@ -52,14 +52,14 @@ net_recv_queue(struct connection *c, size_t len, int flags, //kore_debug("net_recv_queue(%p, %d, %p)", c, len, cb); - nb = (struct netbuf *)kore_malloc(sizeof(*nb)); + nb = kore_malloc(sizeof(*nb)); nb->cb = cb; nb->len = len; nb->owner = c; nb->offset = 0; nb->flags = flags; nb->type = NETBUF_RECV; - nb->buf = (u_int8_t *)kore_malloc(nb->len); + nb->buf = kore_malloc(nb->len); TAILQ_INSERT_TAIL(&(c->recv_queue), nb, list); if (out != NULL) @@ -79,7 +79,7 @@ net_recv_expand(struct connection *c, struct netbuf *nb, size_t len, nb->cb = cb; nb->len += len; - nb->buf = (u_int8_t *)kore_realloc(nb->buf, nb->len); + nb->buf = kore_realloc(nb->buf, nb->len); TAILQ_REMOVE(&(c->recv_queue), nb, list); TAILQ_INSERT_HEAD(&(c->recv_queue), nb, list); diff --git a/src/spdy.c b/src/spdy.c @@ -198,9 +198,9 @@ spdy_header_block_create(int delayed_alloc) kore_debug("spdy_header_block_create()"); - hblock = (struct spdy_header_block *)kore_malloc(sizeof(*hblock)); + hblock = kore_malloc(sizeof(*hblock)); if (delayed_alloc == SPDY_HBLOCK_NORMAL) { - hblock->header_block = (u_int8_t *)kore_malloc(128); + hblock->header_block = kore_malloc(128); hblock->header_block_len = 128; hblock->header_offset = 4; } else { @@ -226,8 +226,7 @@ spdy_header_block_add(struct spdy_header_block *hblock, char *name, char *value) vlen = strlen(value); if ((nlen + vlen + hblock->header_offset) > hblock->header_block_len) { hblock->header_block_len += nlen + vlen + 128; - hblock->header_block = - (u_int8_t *)kore_realloc(hblock->header_block, + hblock->header_block = kore_realloc(hblock->header_block, hblock->header_block_len); } @@ -302,7 +301,7 @@ spdy_stream_get_header(struct spdy_header_block *s, char *header, char **out) kore_debug("found %s header", header); cmp = (char *)(p + nlen + 8); - *out = (char *)kore_malloc(vlen + 1); + *out = kore_malloc(vlen + 1); kore_strlcpy(*out, cmp, vlen + 1); return (KORE_RESULT_OK); } @@ -390,7 +389,7 @@ spdy_ctrl_frame_syn_stream(struct netbuf *nb) return (KORE_RESULT_OK); } - s = (struct spdy_stream *)kore_malloc(sizeof(*s)); + s = kore_malloc(sizeof(*s)); s->prio = syn.prio; s->flags = ctrl.flags; s->wsize = c->wsize_initial; @@ -701,7 +700,7 @@ spdy_zlib_inflate(struct connection *c, u_int8_t *src, size_t len, case Z_OK: have = SPDY_ZLIB_CHUNK - c->z_inflate.avail_out; *olen += have; - *dst = (u_int8_t *)kore_realloc(*dst, *olen); + *dst = kore_realloc(*dst, *olen); memcpy((*dst) + (*olen - have), inflate_buffer, have); if (c->z_inflate.avail_in != 0 || @@ -769,7 +768,7 @@ spdy_zlib_deflate(struct connection *c, u_int8_t *src, size_t len, case Z_OK: have = SPDY_ZLIB_CHUNK - c->z_deflate.avail_out; *olen += have; - *dst = (u_int8_t *)kore_realloc(*dst, *olen); + *dst = kore_realloc(*dst, *olen); memcpy((*dst) + (*olen - have), deflate_buffer, have); if (c->z_deflate.avail_in == 0 && diff --git a/src/utils.c b/src/utils.c @@ -257,7 +257,7 @@ kore_base64_encode(u_int8_t *data, u_int32_t len, char **out) if ((len % 3) != 0) { padding = 3 - (len % 3); plen = len + padding; - pdata = (u_int8_t *)kore_malloc(plen); + pdata = kore_malloc(plen); memcpy(pdata, data, len); memset(pdata + len, 0, padding);