summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAki <please@ignore.pl>2021-08-21 16:17:05 +0200
committerAki <please@ignore.pl>2021-08-21 16:17:05 +0200
commit4c76943de7912996cc6e380a44da9e8f3ea32503 (patch)
tree9a6da26832fa6ad3dce36e8ea139e6d6b6f0bece
parent6cefc948d37cd856d23caf00970ad3565672b016 (diff)
downloadplop-4c76943de7912996cc6e380a44da9e8f3ea32503.zip
plop-4c76943de7912996cc6e380a44da9e8f3ea32503.tar.gz
plop-4c76943de7912996cc6e380a44da9e8f3ea32503.tar.bz2
Added prefix to buffer related functions
-rw-r--r--buffer.c12
-rw-r--r--buffer.h8
-rw-r--r--stream.c6
3 files changed, 13 insertions, 13 deletions
diff --git a/buffer.c b/buffer.c
index ad6ca25..f7e4334 100644
--- a/buffer.c
+++ b/buffer.c
@@ -9,7 +9,7 @@
#include "stream.h"
-void grow(lua_State * L, struct buffer * b)
+void buffer_grow(lua_State * L, struct buffer * b)
{
int allocated = b->allocated + 1024;
@@ -31,13 +31,13 @@ void grow(lua_State * L, struct buffer * b)
b->allocated = allocated;
}
-int read_more(lua_State * L, int fd, struct buffer * in, int minimum_length, lua_KContext ctx)
+int buffer_read_more(lua_State * L, int fd, struct buffer * in, int minimum_length, lua_KContext ctx)
{
const int free_space = in->allocated + in->offset - in->length - 1;
while (free_space < minimum_length)
{
- grow(L, in);
+ buffer_grow(L, in);
}
if (0 < in->offset)
@@ -67,19 +67,19 @@ int read_more(lua_State * L, int fd, struct buffer * in, int minimum_length, lua
return length;
}
-int prepare_at_least(lua_State * L, int fd, struct buffer * in, int minimum_length, lua_KContext ctx)
+int buffer_prepare_at_least(lua_State * L, int fd, struct buffer * in, int minimum_length, lua_KContext ctx)
{
const int remaining_bytes = in->length - in->next;
if (remaining_bytes < minimum_length)
{
- return read_more(L, fd, in, minimum_length, ctx);
+ return buffer_read_more(L, fd, in, minimum_length, ctx);
}
return remaining_bytes;
}
-int until(struct buffer * b, const char * pattern, int pattern_length)
+int buffer_until(struct buffer * b, const char * pattern, int pattern_length)
{
while (b->next + pattern_length <= b->length)
{
diff --git a/buffer.h b/buffer.h
index 66f8f02..d3153c7 100644
--- a/buffer.h
+++ b/buffer.h
@@ -11,7 +11,7 @@ struct buffer
int allocated;
};
-void grow(lua_State *, struct buffer *);
-int read_more(lua_State *, const int, struct buffer *, const int, lua_KContext);
-int prepare_at_least(lua_State *, const int, struct buffer *, const int, lua_KContext);
-int until(struct buffer *, const char *, const int);
+void buffer_grow(lua_State *, struct buffer *);
+int buffer_read_more(lua_State *, const int, struct buffer *, const int, lua_KContext);
+int buffer_prepare_at_least(lua_State *, const int, struct buffer *, const int, lua_KContext);
+int buffer_until(struct buffer *, const char *, const int);
diff --git a/stream.c b/stream.c
index cb5eff5..f7c75e0 100644
--- a/stream.c
+++ b/stream.c
@@ -155,8 +155,8 @@ int stream_readk(lua_State * L, int status, lua_KContext ctx)
int remaining_bytes;
do
{
- remaining_bytes = prepare_at_least(L, s->fd, &s->in, (int) pattern_length, ctx);
- offset = until(&s->in, pattern, (int) pattern_length);
+ remaining_bytes = buffer_prepare_at_least(L, s->fd, &s->in, (int) pattern_length, ctx);
+ offset = buffer_until(&s->in, pattern, (int) pattern_length);
}
while (-1 == offset && 0 < remaining_bytes);
@@ -225,7 +225,7 @@ int stream_write(lua_State * L)
while (free_space < (int) data_length)
{
- grow(L, &s->out);
+ buffer_grow(L, &s->out);
free_space = s->out.allocated - s->out.length;
}