-struct memcached_binary_protocol_st {
- struct memcached_binary_protocol_callback_st *callback;
- memcached_binary_protocol_recv_func recv;
- memcached_binary_protocol_send_func send;
- char *input_buffer;
+/*
+ * I don't really need the following two functions as function pointers
+ * in the instance handle, but I don't want to put them in the global
+ * namespace for those linking statically (personally I don't like that,
+ * but some people still do). If it ever shows up as a performance thing
+ * I'll look into optimizing this ;-)
+ */
+typedef bool (*drain_func)(memcached_protocol_client_st *client);
+typedef protocol_binary_response_status (*spool_func)(memcached_protocol_client_st *client,
+ const void *data,
+ size_t length);
+
+/**
+ * Definition of the per instance structure.
+ */
+struct memcached_protocol_st {
+ memcached_binary_protocol_callback_st *callback;
+ memcached_protocol_recv_func recv;
+ memcached_protocol_send_func send;
+
+ /*
+ * I really don't need these as funciton pointers, but I don't want
+ * to clutter the namespace if someone links statically.
+ */
+ drain_func drain;
+ spool_func spool;
+
+ /*
+ * To avoid keeping a buffer in each client all the time I have a
+ * bigger buffer in the instance that I read to initially, and then
+ * I try to parse and execute as much from the buffer. If I wasn't able
+ * to process all data I'll keep that in a per-connection buffer until
+ * the next time I can read from the socket.
+ */
+ uint8_t *input_buffer;