#include <stdio.h>
#include <stdint.h>
typedef uint64_t XLogRecPtr;
typedef uint32_t uint32;
#define MAXPG_LSNLEN 17
#define LSN_FORMAT "%X/%X"
#define LSN_FORMAT_ARG(lsn) (uint32) ((lsn) >> 32), (uint32) (lsn)
char *
pg_lsn_out_buffer(XLogRecPtr lsn, char *buf)
{
printf("pg_lsn_out_buffer: sizeof(buf) = %lu\n", sizeof(buf));
snprintf(buf, sizeof(buf), LSN_FORMAT, LSN_FORMAT_ARG(lsn));
return buf;
}
char *
pg_lsn_out_buffer1(XLogRecPtr lsn, char *buf, size_t len)
{
printf("pg_lsn_out_buffer1: sizeof(buf) = %lu, len = %lu\n", sizeof(buf), len);
snprintf(buf, len, LSN_FORMAT, LSN_FORMAT_ARG(lsn));
return buf;
}
int
main(void)
{
char buf[MAXPG_LSNLEN + 1];
XLogRecPtr lsn = 1234567UL;
printf("main: sizeof(buf) = %lu\n", sizeof(buf));
pg_lsn_out_buffer(lsn, buf);
printf("buffer's content from pg_lsn_out_buffer: %s\n", buf);
pg_lsn_out_buffer1(lsn, buf, sizeof(buf));
printf("buffer's content from pg_lsn_out_buffer1: %s\n", buf);
return 0;
}