1 
2 #include "upb/sink.h"
3 
upb_bufsrc_putbuf(const char * buf,size_t len,upb_bytessink sink)4 bool upb_bufsrc_putbuf(const char *buf, size_t len, upb_bytessink sink) {
5   void *subc;
6   bool ret;
7   upb_bufhandle handle = UPB_BUFHANDLE_INIT;
8   handle.buf = buf;
9   ret = upb_bytessink_start(sink, len, &subc);
10   if (ret && len != 0) {
11     ret = (upb_bytessink_putbuf(sink, subc, buf, len, &handle) >= len);
12   }
13   if (ret) {
14     ret = upb_bytessink_end(sink);
15   }
16   return ret;
17 }
18