LevelDB Explained - Understanding Advanced C++ Techniques
0 CommentThe overall code of LevelDB is quite understandable, without using many esoteric C++ techniques. However, there are some implementations that are relatively uncommon, such as flexible arrays, symbol exporting for linking, and Pimpl class design. This article will review these advanced C++ techniques to help better understand the implementation of LevelDB.
Flexible Arrays
In the LRUHandle structure definition in util/cache.cc, there’s a flexible array member char key_data[1]
, used to implement variable-length data structures in C/C++.
1 | struct LRUHandle { |