// newBuffer creates a pull of buffers.
764979
func newBuffer(size, numbuffers int) *buffer {
	return &buffer{
		size:    size,
		buffers: make([][]byte, 0, numbuffers),
		ptr:     -1,
	}
}
574242
func NewRingBuffer(size int) RingBuffer {
	rb := &ringBuffer{}
	rb.start = &valueLink{}
	rb.end = rb.start
	if size < 2 {
		size = 2
	}
	for i := 0; i < size-1; i++ {
		link := &valueLink{}
		rb.end.next = link
		rb.end = link
	}
	rb.end.next = rb.start
	return rb
}
667329
func NewBuffer(it SeriesIterator, delta int64) *BufferedSeriesIterator {
	return &BufferedSeriesIterator{
		it:       it,
		buf:      newSampleRing(delta, 16),
		lastTime: math.MinInt64,
	}
}
385297
func NewParser(buf []byte) (*Parser, error) {
	r := bytes.NewReader(buf)
	return NewStreamParser(r)
}
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)),
	}
}
775816
func NewBuffer(size int) *Buffer {
	return &Buffer{size: size,
		ws:     make([]io.Writer, 0, 1),
		buffer: make([][]byte, 0, size),
	}
}
602076
func NewBufferPool(baseline int) *BufferPool {
	if baseline <= 0 {
		panic("baseline can't be <= 0")
	}
	p := &BufferPool{
		baseline0: baseline,
		baseline:  [...]int{baseline / 4, baseline / 2, baseline * 2, baseline * 4},
		closeC:    make(chan struct{}, 1),
	}
	for i, cap := range []int{2, 2, 4, 4, 2, 1} {
		p.pool[i] = make(chan []byte, cap)
	}
	go p.drain()
	return p
}
851252
func (lib *Lib) MakeBufferString(content string) (*Buffer, error) {
	return lib.MakeBufferBytes([]byte(content))
}
370174
func WithBuffer(n int) JSONSourceOption {
	return func(j *JSONSource) {
		if n > -1 {
			j.records = make(chan record, n)
		}
	}
}
105567
func NewBufferedForwarder(ctx context.Context, config *Config, sendTo signalfx.Sink, closeIt, afterStartup func() error, logger log.Logger, debugEnpoints func() map[string]http.Handler) *BufferedForwarder {
	config = pointer.FillDefaultFrom(config, DefaultConfig).(*Config)
	logCtx := log.NewContext(logger).With(logkey.Struct, "BufferedForwarder")
	logCtx.Log(logkey.Config, config)
	context, cancel := context.WithCancel(ctx)
	ret := &BufferedForwarder{
		stopFunc:       cancel,
		stopContext:    context,
		dpChan:         make(chan []*datapoint.Datapoint, *config.BufferSize),
		eChan:          make(chan []*event.Event, *config.BufferSize),
		tChan:          make(chan []*trace.Span, *config.BufferSize),
		config:         config,
		sendTo:         sendTo,
		closeSender:    closeIt,
		afterStartup:   afterStartup,
		logger:         logCtx,
		checker:        config.Checker,
		cdim:           config.Cdim,
		identifier:     *config.Name,
		debugEndpoints: debugEnpoints,
	}
	ret.start()
	return ret
}
1025630
func NewArrayBuffer(b []byte) *Object {
	slice := InternalObject(b)
	offset := slice.Get("$offset").Int()
	length := slice.Get("$length").Int()
	return slice.Get("$array").Get("buffer").Call("slice", offset, offset+length)
}
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
}
263354
func (c *Context) IsBuffer(buffer *js.Object) bool {
	return c.Call("isBuffer", buffer).Bool()
}
529295
func newBuffer(nc net.Conn) buffer {
	fg := make([]byte, defaultBufSize)
	return buffer{
		buf:  fg,
		nc:   nc,
		dbuf: [2][]byte{fg, nil},
	}
}
1213010
func NewPool(New func() Buffer) Pool {
	return &pool{
		pool: sync.Pool{
			New: func() interface{} {
				return New()
			},
		},
	}
}
583657
func NewBufferPool(size int, mem int) (bp *BufferPool) {
	return &BufferPool{
		c:     make(chan *bytes.Buffer, size),
		alloc: mem,
	}
}
1104031
func NewDisplayBuffer(width, height, pageSize int) *DisplayBuffer {
	s := &DisplayBuffer{
		width:    width,
		height:   height,
		pageSize: pageSize,
	}
	s.buffer = make([]byte, s.Size())
	return s
}