bytes_after_return in XGetWindowProperty man pages
Peter Kozich (GM)
peter.t.kozich at gmail.com
Sun Oct 13 09:58:28 UTC 2024
Dear,
Everywhere in all manuals on XGetWindowProperty() I see these formulas:
N = actual length of the stored property in bytes
(even if the format is 16 or 32)
I = 4 * long_offset
T = N - I
L = MINIMUM(T, 4 * long_length)
A = N - (I + L)
It was difficult for me to understand them, and at first I thought it
was because they were merely anti-intutive a little bit. But then, my
opinion changed, and now I think they are plain wrong.
What I think is correct is this:
N = actual length of the stored property in bytes
(even if the format is 16 or 32)
I = 4 * long_offset
===> T = N + I
L = MINIMUM(T, 4 * long_length)
===> A = N - (L - I)
Now, with a too small buffer we have:
A = N - (4*long_length - I) = I + N - 4*long_length
and with a large one:
A = N - (N + I - I) = 0
And now, all of a sudden, this is intuitive:
- T is the total needed buffer size (or, even better: T = I + N),
- L is the index one past the retrieved data,
- L - I is the length of the retrieved data, which is either
4*long_length - I or N.
Whats's your opinion?
br
PK
More information about the xorg
mailing list