google / google/leveldb

Add a Get API which allows for caller-allocated result buffer storage ( e.g. on stack )

Open
#141 2 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
C++
Stars
39.4k
Forks
8.2k
PR merge metrics
No merged PRs in 30d

Description

Original [issue 135](https://code.google.com/p/leveldb/issues/detail?id=135) created by jvb127 on 2013-01-03T17:35:09.000Z:

The current API provides:

``` c++
virtual Status Get(const ReadOptions& options,
const Slice& key, std::string* value) = 0;
```

A downside of this API is that it uses dynamic memory allocation in std::string

It would be nice to have an additional API call:

``` c++
virtual Status Get(const ReadOptions& options,
const Slice& key, char* buf, size_t* bufsize ) = 0;
```

This would allow a stack-based buffer. It would require a new status code "buffer too small", the bufsize parameter is a pointer to receive the size of the data copied / required

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.