From aa2121b61c96635e461260890b26cabf5eff3a9a Mon Sep 17 00:00:00 2001 From: Yuichi Nishiwaki Date: Fri, 19 Feb 2016 00:20:15 +0900 Subject: [PATCH] remove blob.h --- contrib/40.srfi/src/106.c | 6 ++---- extlib/benz/blob.c | 8 ++++++++ extlib/benz/include/picrin.h | 1 - extlib/benz/include/picrin/blob.h | 8 -------- extlib/benz/include/picrin/object.h | 10 ++++++++++ extlib/benz/port.c | 1 + 6 files changed, 21 insertions(+), 13 deletions(-) diff --git a/contrib/40.srfi/src/106.c b/contrib/40.srfi/src/106.c index ef31ec43..2c3e045d 100644 --- a/contrib/40.srfi/src/106.c +++ b/contrib/40.srfi/src/106.c @@ -188,8 +188,7 @@ pic_socket_socket_send(pic_state *pic) pic_value obj; struct pic_blob *bv; const unsigned char *cursor; - int flags = 0; - size_t remain, written; + int flags = 0, remain, written; struct pic_socket_t *sock; pic_get_args(pic, "ob|i", &obj, &bv, &flags); @@ -198,8 +197,7 @@ pic_socket_socket_send(pic_state *pic) sock = pic_socket_data_ptr(obj); ensure_socket_is_open(pic, sock); - cursor = bv->data; - remain = bv->len; + cursor = pic_blob(pic, bv, &remain); written = 0; errno = 0; while (remain > 0) { diff --git a/extlib/benz/blob.c b/extlib/benz/blob.c index a7c053f5..6cc1eaac 100644 --- a/extlib/benz/blob.c +++ b/extlib/benz/blob.c @@ -3,6 +3,7 @@ */ #include "picrin.h" +#include "picrin/object.h" struct pic_blob * pic_blob_value(pic_state *pic, const unsigned char *buf, int len) @@ -18,6 +19,13 @@ pic_blob_value(pic_state *pic, const unsigned char *buf, int len) return bv; } +unsigned char * +pic_blob(pic_state PIC_UNUSED(*pic), struct pic_blob *blob, int *len) +{ + *len = blob->len; + return blob->data; +} + static pic_value pic_blob_bytevector_p(pic_state *pic) { diff --git a/extlib/benz/include/picrin.h b/extlib/benz/include/picrin.h index 9566cd7b..ab3c9796 100644 --- a/extlib/benz/include/picrin.h +++ b/extlib/benz/include/picrin.h @@ -258,7 +258,6 @@ int pic_str_hash(pic_state *, struct pic_string *); #include "picrin/state.h" -#include "picrin/blob.h" #include "picrin/cont.h" #include "picrin/data.h" #include "picrin/dict.h" diff --git a/extlib/benz/include/picrin/blob.h b/extlib/benz/include/picrin/blob.h index 68281e82..24ca9e2c 100644 --- a/extlib/benz/include/picrin/blob.h +++ b/extlib/benz/include/picrin/blob.h @@ -9,14 +9,6 @@ extern "C" { #endif -struct pic_blob { - PIC_OBJECT_HEADER - unsigned char *data; - int len; -}; - -#define pic_blob_ptr(v) ((struct pic_blob *)pic_obj_ptr(v)) - #if defined(__cplusplus) } #endif diff --git a/extlib/benz/include/picrin/object.h b/extlib/benz/include/picrin/object.h index ac7615e5..6a5d5b16 100644 --- a/extlib/benz/include/picrin/object.h +++ b/extlib/benz/include/picrin/object.h @@ -10,6 +10,16 @@ extern "C" { #endif +/* blob */ + +struct pic_blob { + PIC_OBJECT_HEADER + unsigned char *data; + int len; +}; + +#define pic_blob_ptr(v) ((struct pic_blob *)pic_obj_ptr(v)) + /* string */ struct pic_string { diff --git a/extlib/benz/port.c b/extlib/benz/port.c index 19886305..5169978b 100644 --- a/extlib/benz/port.c +++ b/extlib/benz/port.c @@ -3,6 +3,7 @@ */ #include "picrin.h" +#include "picrin/object.h" static pic_value pic_assert_port(pic_state *pic)