Ejemplo n.º 1
0
        // ~ByteBuffer()
        // {
        //     if (_refCount != 0)
        //     {
        //         Debug.LogErrorFormat("ByteBuffer leaked {0} {1}\n{2}", GetHashCode(), _refCount, _stacktrace ?? "");
        //     }
        // }

        public ByteBuffer Release()
        {
            --_refCount;
            if (_refCount == 0)
            {
                _writePosition = 0;
                _readPosition  = 0;
                _stacktrace    = null;
                if (_allocator != null)
                {
                    // Debug.LogFormat("<< ByteBuffer released {0}", GetHashCode());
                    _allocator.Recycle(this);
                }
                return(null);
            }
            return(this);
        }