Skip to content

Conversation

@shuxin
Copy link

@shuxin shuxin commented Jan 4, 2025

sorry for trick, maybe there will be a better way

@jd-boyd jd-boyd force-pushed the main branch 6 times, most recently from 54799c7 to f7fecf6 Compare June 16, 2025 06:08
@jd-boyd
Copy link
Owner

jd-boyd commented Sep 3, 2025

I'm sorry, for the delay in responding, but if you are still interested, I would like to see test(s) added for this.

@shuxin
Copy link
Author

shuxin commented Sep 4, 2025

lzo have no header like zstd or lz4.
I want to alloc larger buffer and try decompress lzo data without size info.
But you check the new_len and out_len strictly.

I know, it's a trick. Maybe there will be a better solution.

size_guess = len(in)*2
while True:
    if try_decompress(...): # allow a incorrect size.
        break
    size_guess *= 2

@jd-boyd
Copy link
Owner

jd-boyd commented Sep 19, 2025

It looks to me like your change makes an initial guess of 1 byte output length, which is unlikely to ever be a good guess, especially since there is no resizing if buflen is less than needed. You mention a possible better solution in python, but not as an update to the pull request. I think you can fairly safely guess that a default buflen should be at least as long as the input length. Input length * 2 might be going too far. You could look at what other libraries do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants