Comments (4)
Zeroing a block of memory is usually very fast. Requiring the memory to be 0 is changing the API contract.
Most users will actually call the encode function with scratch_buffer=NULL.
Users calling it with non NULL probably want to avoid re-allocating it for multiple calls. In that case, someone has to clear the buffer before each call anyway, and it will be done inside the LZFSE library.
from lzfse.
Zeroing a block of memory is usually very fast.
True, but calloc is often faster since the OS or libc may have a block of already zeroed memory sitting around. AFAIK it's pretty common for operating systems to keep some blobs of zeroed memory around just waiting for a calloc().
Requiring the memory to be 0 is changing the API contract.
Since the library isn't installed, I'm not sure how much benefit there is to committing to an API/ABI. IMHO it would be better to flesh out issues, then commit to an API/ABI. However, if you want to commit to the API right now I understand.
If that's the case, though, you should probably be installing the header and shared library (and preferably a pkg-config file). Should I put together a PR for that?
Most users will actually call the encode function with scratch_buffer=NULL.
Perhaps I'm missing something, but does the existing code actually work with NULL for the scratch buffer? I don't see any mallocs or callocs in lzfse, except for in lzfse_main.cā¦ If I pass NULL to lzfse_encode_buffer
in the Squash plugin it crashes.
If nothing else, I guess that is a pretty strong indicator that people aren't passing NULL there.
Users calling it with non NULL probably want to avoid re-allocating it for multiple calls. In that case, someone has to clear the buffer before each call anyway, and it will be done inside the LZFSE library.
Maybe, but that can get complicated pretty quickly in a multi-threaded application. You would need a pool of memory, which is basically what malloc/calloc provides (except it's probably better-optimized than whatever some random programmer will come up with).
from lzfse.
I'd prefer the LZFSE API to match the Compression API we have been shipping in macOS and iOS since last year. It doesn't require the scratch_buffer to be zeroed, and allows NULL.
Actually the lzfse.h header here documents the NULL case as valid, but you are right: there is no code handling this case. I'll need to fix this ASAP.
from lzfse.
I see you filed #28, so I may as well close this.
from lzfse.
Related Issues (20)
- No portable fallbacks for GCC builtins
- gzip switch compatibility HOT 1
- Library release versioning HOT 4
- error when using on centos 7
- Conan package
- Unaligned loads in decoder fail on asm.js. HOT 2
- Problem with lzfse_decode_buffer_with_scratch HOT 1
- Crash (double free) when compressing empty file or pipe HOT 3
- I want to compress a file use lzfse on system-level ,like lzvn or zlib,what could I do? HOT 1
- Attempt to decode throws a malloc error HOT 3
- how to inline compile assembly HOT 2
- Try impl on Android but app crashes
- [Question] How to build this as dylib (consumable in a .NET Core project) HOT 1
- UBsan flags 2 loops in lzfse_decode_base.c with "Pointer Overflow" warnings HOT 2
- https://github.com/sbingner/lzfse.git HOT 1
- lzfse decode issue - msys2 build HOT 1
- add support for LZBITMAP HOT 4
- Not able to decompress iCloud backup file when size is greater than 64KB
- Compression of inputs larger than 2GiB degraded
- Memory-related crash
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
š Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ššš
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ā¤ļø Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lzfse.