fork of https://github.com/oxigraph/rocksdb and https://github.com/facebook/rocksdb for nextgraph and oxigraph
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
1.1 KiB
38 lines
1.1 KiB
// Copyright (c) 2011 The LevelDB Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file. See the AUTHORS file for names of contributors.
|
|
//
|
|
// Arena class defines memory allocation methods. It's used by memtable and
|
|
// skiplist.
|
|
|
|
#ifndef STORAGE_LEVELDB_INCLUDE_ARENA_H_
|
|
#define STORAGE_LEVELDB_INCLUDE_ARENA_H_
|
|
|
|
namespace leveldb {
|
|
|
|
class Arena {
|
|
public:
|
|
Arena() {};
|
|
virtual ~Arena() {};
|
|
|
|
// Return a pointer to a newly allocated memory block of "bytes" bytes.
|
|
virtual char* Allocate(size_t bytes) = 0;
|
|
|
|
// Allocate memory with the normal alignment guarantees provided by malloc.
|
|
virtual char* AllocateAligned(size_t bytes) = 0;
|
|
|
|
// Returns an estimate of the total memory used by arena.
|
|
virtual const size_t ApproximateMemoryUsage() = 0;
|
|
|
|
// Returns the total number of bytes in all blocks allocated so far.
|
|
virtual const size_t MemoryAllocatedBytes() = 0;
|
|
|
|
private:
|
|
// No copying allowed
|
|
Arena(const Arena&);
|
|
void operator=(const Arena&);
|
|
};
|
|
|
|
} // namespace leveldb
|
|
|
|
#endif // STORAGE_LEVELDB_INCLUDE_ARENA_H_
|
|
|