Here, we cannot use sizeof(but) to get the buf size, because it is a pointer, so it always 8 bytes on 64-bit or 4 bytes on 32-bit machine.
For an array, the sizeof() returns the size of memory consumed by the array. See section "Application to arrays" at https://en.wikipedia.org/wiki/Sizeof.
That’s true! However, in pg_lsn_out_buffer(), it converts to a pointer, not an array. See the following test:
Ah! Thanks for pointing that out. I have fixed this in my repository. However, from Alvaro's reply it looks like the approach is not acceptable, so I am not posting the fixed version here.