// NewBuffer 新建一个 Buffer。
// w 最终输出的方向；当 size<=1 时，所有的内容都不会缓存，直接向 w 输出。
775816
func NewBuffer(size int) *Buffer {
	return &Buffer{size: size,
		ws:     make([]io.Writer, 0, 1),
		buffer: make([][]byte, 0, size),
	}
}
1299412
func NewCircularBuffer(size uint) *CircularBuffer {
	return &CircularBuffer{
		buffer: make([]interface{}, size),
		size:   size,
		avail:  make(chan bool, size),
	}
}
424015
func (buf *SharedBuffer) NewChannel() SimpleChannel {
	ch := &sharedBufferChannel{
		in:  make(chan interface{}),
		out: make(chan interface{}),
		buf: queue.New(),
	}
	buf.in <- ch
	return ch
}
1350944
func New() (m *MultipartStreamer) {
	m = &MultipartStreamer{bodyBuffer: new(bytes.Buffer)}

	m.bodyWriter = multipart.NewWriter(m.bodyBuffer)
	boundary := m.bodyWriter.Boundary()
	m.ContentType = "multipart/form-data; boundary=" + boundary

	closeBoundary := fmt.Sprintf("\r\n--%s--\r\n", boundary)
	m.closeBuffer = bytes.NewBufferString(closeBoundary)

	return
}
384014
func (w *Window) GetFramebufferSize() (width, height int) {
	var wi, h C.int
	C.glfwGetFramebufferSize(w.data, &wi, &h)
	return int(wi), int(h)
}
1359836
func NewLogBuffer(message_buffer int, interceptedLoggers []*log.Logger) *LogBuffer {
	if message_buffer <= 0 || len(interceptedLoggers) == 0 {
		panic("message_buffer must be >0 and at least one logger to intercept must be given")
	}
	return &LogBuffer{
		messages:          ring.New(message_buffer),
		message_buffer:    message_buffer,
		loggers:           interceptedLoggers,
		originalLoggerOut: make([]io.Writer, len(interceptedLoggers)),
	}
}
21272
func NewWriter(w io.Writer) *Writer {
	if wr, ok := w.(*Writer); ok {
		return wr
	}
	return &Writer{
		w:   w,
		buf: make([]byte, 0, DefaultWriterSize),
	}
}
907886
func (bf *BufferFactory) RequestBuffer(size int) *bytes.Buffer {
	buf := bf.Request(size)
	return bytes.NewBuffer(buf[:0])
}
1367123
func newBufferedBody(src io.ReadCloser) (*bufferedBody, error) {
	if src == nil {
		return nil, nil
	}
	b, err := ioutil.ReadAll(src)
	src.Close()
	if err != nil {
		return nil, err
	}
	return &bufferedBody{
		Reader: bytes.NewReader(b),
	}, nil
}
1164782
func NewByteBufPool(capacity int, pool Pool) *ByteBuf {
	return &ByteBuf{
		capacity:    capacity,
		buf:         pool.Alloc(capacity),
		readerIndex: 0,
		writerIndex: 0,
		pool:        pool,
	}
}
971089
func (c *Client) QueryBuffer(num int32) (*Buffer, error) {
	if err := c.oscConn.Send(osc.Message{
		Address: bufferQueryAddress,
		Arguments: osc.Arguments{
			osc.Int(num),
		},
	}); err != nil {
		return nil, errors.Wrap(err, "sending buffer query message")
	}
	return c.awaitBufInfoReply()
}
529295
func newBuffer(nc net.Conn) buffer {
	fg := make([]byte, defaultBufSize)
	return buffer{
		buf:  fg,
		nc:   nc,
		dbuf: [2][]byte{fg, nil},
	}
}
96957
func goFramebufferSizeCB(window unsafe.Pointer, width, height C.int) {
	w := windows.get((*C.GLFWwindow)(window))
	w.fFramebufferSizeHolder(w, int(width), int(height))
}
105082
func BytesBuffer() *bytes.Buffer {
	buf := bytesBuffer.Get().(*bytes.Buffer)
	buf.Reset()
	return buf
}
1077770
func (w *spanWorker) newBuffer() {
	for {
		select {
		// check if the sink is closing and return if so
		// reading from a.closing will only return a value if the a.closing channel is closed
		// nothing should ever write into it
		case <-w.closing:
			// signal that the worker is done
			w.done <- true
			return
		case msg := <-w.input:
			// process the Datapoint Message
			w.bufferFunc(msg)
		}
	}
}
75397
func New() *Splitter {
	s := &Splitter{
		buffer: []byte{},
		output: make(chan []byte, 1000),
		done:   false, // Explicit declaration though default
	}

	go s.analyze()

	return s
}
877701
func (logger *Logger) getBuffer() *buffer {
	logger.bufferListMutex.Lock()
	b := logger.bufferList
	if b != nil {
		logger.bufferList = b.next
	}
	logger.bufferListMutex.Unlock()
	if b == nil {
		b = new(buffer)
	} else {
		b.next = nil
		b.Reset()
	}
	return b
}