X-Git-Url: http://the.earth.li/gitweb/?a=blobdiff_plain;f=charfuncs.c;h=778df1ca477732fac168895fc3094e45af329ae4;hb=408ea0b9ceafdc9f861701cfb14b57d09aa47777;hp=f509fc8653948e6645b8c3c797698de7cab27bba;hpb=58d762ea573eb3cfea626bb52ea7a99e24b8a0aa;p=onak.git diff --git a/charfuncs.c b/charfuncs.c index f509fc8..778df1c 100644 --- a/charfuncs.c +++ b/charfuncs.c @@ -4,11 +4,10 @@ * Jonathan McDowell * * Copyright 2002 Project Purple - * - * $Id: charfuncs.c,v 1.4 2003/10/04 10:21:40 noodles Exp $ */ #include +#include #include #include #include @@ -24,12 +23,11 @@ int buffer_fetchchar(void *ctx, size_t count, unsigned char *c) { struct buffer_ctx *buf = NULL; - size_t i; buf = (struct buffer_ctx *) ctx; - for (i = 0; i < count; i++) { - c[i] = buf->buffer[buf->offset++]; - } + + memcpy(c, &buf->buffer[buf->offset], count); + buf->offset += count; return (((buf->offset) == (buf->size)) ? 1 : 0); } @@ -48,7 +46,6 @@ int buffer_putchar(void *ctx, size_t count, unsigned char *c) { struct buffer_ctx *buf = NULL; size_t newsize = 0; - size_t i; buf = (struct buffer_ctx *) ctx; @@ -59,11 +56,10 @@ int buffer_putchar(void *ctx, size_t count, unsigned char *c) buf->buffer = realloc(buf->buffer, newsize); buf->size = newsize; } - - for (i = 0; i < count; i++) { - buf->buffer[buf->offset++] = c[i]; - } + memcpy(&buf->buffer[buf->offset], c, count); + buf->offset += count; + return 1; }