On macOS and other BSD OSes, there exists a memory.h system header (which just includes <string.h>). pinentry/pinentry-curses.c should include pinentry’s own memory.h using #include "memory.h" (as already done elsewhere in pinentry) rather than #include <memory.h> to prevent a system memory.h header from taking precedence and leading to implicit declaration of secmem_free() (which Xcode clang 12 and LLVM clang 16 consider an error by default rather than a warning).
This issue was observed by MacPorts (see https://trac.macports.org/ticket/61421) for the defunct pinentry-mac fork, which is where I originally tried submitting this change to (see https://github.com/GPGTools/pinentry-mac/pull/8).