Pi4J / pi4j-v2

Pi4J Version 2.0
Apache License 2.0
266 stars 54 forks source link

LinuxFile reused scratch buffers ensuring size was usable. But the … #331

Closed taartspi closed 5 months ago

taartspi commented 5 months ago

…limit value cannot be modified so later usage failed as an intended overwrite

Modified both methods that return a buffer. The methods ensured the an existing buffer was large enough for the new request and returned it. But its new usage may containa greater limit value. I could not alter the limit value of an existing buffer, instead if an old buffer exists I remove it an allocate a new buffer.

This is an answer to a post. If you agree with this, can you spin a 2.5.1 snap shot so this user can progress. I did not research how many attributes we needed to compare if we wanted to reuse an existing buffer @eitch @FDelporte

eitch commented 5 months ago

Further if i look at the old code, then we reuse the buffer... Are we sure this is ok, to just always write a new buffer? Are we not using the buffers in multiple calls in some way?

taartspi commented 5 months ago

My last sentence in the pr about further validation for reuse. We could test if the limit is the same or now less and i think reuse is ok. I would need to decide if there are other attributes that require similar validation. And your code suggestion. I must retest but i think this will not handle the new limit being greater. Will be late my daytime before i can do this work

taartspi commented 5 months ago

-Git repeated saying that the push failed for my local being behind. Seems it did accomplish something each attempt until I figured out how to fix this without using some dangerous force. That left these extra commits, sorry about that.