Add pg_add_size_overflow() and friends
authorJacob Champion <[email protected]>
Mon, 24 Nov 2025 17:59:38 +0000 (09:59 -0800)
committerJacob Champion <[email protected]>
Mon, 24 Nov 2025 17:59:38 +0000 (09:59 -0800)
commit8934f2136cd82333fd148954a13a8ab01f7bd7ef
tree3e92b92bb156dea504dcf76cd949d4b17998ea4a
parentf1881c7dd32cf5f429f6bd525b5cbacef3bb9c99
Add pg_add_size_overflow() and friends

Commit 600086f47 added (several bespoke copies of) size_t addition with
overflow checks to libpq. Move this to common/int.h, along with
its subtraction and multiplication counterparts.

pg_neg_size_overflow() is intentionally omitted; I'm not sure we should
add SSIZE_MAX to win32_port.h for the sake of a function with no
callers.

Reviewed-by: Chao Li <[email protected]>
Reviewed-by: Michael Paquier <[email protected]>
Discussion: https://postgr.es/m/CAOYmi%2B%3D%2BpqUd2MUitvgW1pAJuXgG_TKCVc3_Ek7pe8z9nkf%2BAg%40mail.gmail.com
src/include/common/int.h
src/interfaces/libpq/fe-exec.c
src/interfaces/libpq/fe-print.c
src/interfaces/libpq/fe-protocol3.c