LLVM API Documentation
#include <Compressor.h>
Low Level Interface | |
typedef unsigned( | OutputDataCallback )(char *&buffer, unsigned &size, void *context) |
Output callback function type. | |
static uint64_t | compress (const char *in, unsigned size, OutputDataCallback *cb, void *context=0) |
Compress a block of memory. | |
static uint64_t | decompress (const char *in, unsigned size, OutputDataCallback *cb, void *context=0) |
Decompress a block of memory. | |
Static Public Member Functions | |
High Level Interface | |
static uint64_t | compressToNewBuffer (const char *in, unsigned size, char *&out) |
Compress memory to a new memory buffer. | |
static uint64_t | compressToStream (const char *in, unsigned size, std::ostream &out) |
Compress memory to a file. | |
static uint64_t | decompressToNewBuffer (const char *in, unsigned size, char *&out) |
Decompress memory to a new memory buffer. | |
static uint64_t | decompressToStream (const char *in, unsigned size, std::ostream &out) |
Decompress memory to a stream. |
This class provides an abstraction for compression and decompression of a block of memory. The algorithm used here is currently bzip2 but that may change without notice. Should newer algorithms prove to compress bytecode better than bzip2, that newer algorithm will be added, but won't replace bzip2. This interface allows us to abstract the notion of compression and deal with alternate compression schemes over time. The type of compression used can be determined by inspecting the first byte of the compressed output. Currently value '0' means no compression was used (for very small files) and value '2' means bzip2 compression was used. The Compressor is intended for use with memory mapped files where the entire data block to be compressed or decompressed is available in memory. However, output can be gathered in repeated calls to a callback. Utilities for sending compressed or decompressed output to a stream or directly to a memory block are also provided.
Definition at line 38 of file Compressor.h.
|
Output callback function type.
A callback function type used by the Compressor's low level interface to get the next chunk of data to which (de)compressed output will be written. This callback completely abstracts the notion of how to handle the output data of compression or decompression. The callback is responsible for determining both the storage location and the size of the output. The callback may also do other things with the data such as write it, transmit it, etc. Note that providing very small values for
Definition at line 108 of file Compressor.h. |
|
Compress a block of memory.
This function does the compression work. The block of memory starting at
Definition at line 241 of file Compressor.cpp. References bz_stream::avail_in, bz_stream::avail_out, BZ2_bzCompress, BZ2_bzCompressEnd, BZ2_bzCompressInit, BZ_CONFIG_ERROR, BZ_FINISH, BZ_FINISH_OK, BZ_MEM_ERROR, BZ_OK, BZ_PARAM_ERROR, BZ_SEQUENCE_ERROR, BZ_STREAM_END, bz_stream::bzalloc, bz_stream::bzfree, getdata(), bz_stream::next_in, bz_stream::next_out, NULLCOMP_compress(), NULLCOMP_end(), NULLCOMP_init(), bz_stream::opaque, bz_stream::total_out_hi32, bz_stream::total_out_lo32, and llvm::utostr(). Referenced by compressToNewBuffer(), and compressToStream(). |
|
Compress memory to a new memory buffer.
This method compresses a block of memory pointed to by
Definition at line 329 of file Compressor.cpp. References compress(). Referenced by llvm::Archive::writeMember(). |
|
Compress memory to a file.
This method compresses a block of memory pointed to by
Definition at line 337 of file Compressor.cpp. References compress(). Referenced by llvm::WriteBytecodeToFile(). |
|
Decompress a block of memory.
This function does the decompression work. The block of memory starting at
Definition at line 352 of file Compressor.cpp. References bz_stream::avail_in, bz_stream::avail_out, BZ2_bzDecompress, BZ2_bzDecompressEnd, BZ2_bzDecompressInit, BZ_CONFIG_ERROR, BZ_DATA_ERROR, BZ_DATA_ERROR_MAGIC, BZ_MEM_ERROR, BZ_OK, BZ_PARAM_ERROR, BZ_STREAM_END, bz_stream::bzalloc, bz_stream::bzfree, getdata(), bz_stream::next_in, bz_stream::next_out, NULLCOMP_decompress(), NULLCOMP_end(), NULLCOMP_init(), bz_stream::opaque, bz_stream::total_out_hi32, and bz_stream::total_out_lo32. Referenced by decompressToNewBuffer(), and decompressToStream(). |
|
Decompress memory to a new memory buffer.
This method decompresses a block of memory pointed to by
Definition at line 441 of file Compressor.cpp. References decompress(). |
|
Decompress memory to a stream.
This method decompresses a block of memory pointed to by
Definition at line 449 of file Compressor.cpp. References decompress(). |