Message-ID: From: "faviansamatha (@faviansamatha)" To: "postgresql-interfaces/psqlodbc" Date: Fri, 11 Apr 2025 21:26:40 +0000 Subject: [postgresql-interfaces/psqlodbc] PR #107: fix: use memset if memset_s is not available List-Id: X-GitHub-Author-Id: 60306813 X-GitHub-Author-Login: faviansamatha X-GitHub-Issue: 107 X-GitHub-Repo: postgresql-interfaces/psqlodbc X-GitHub-State: merged X-GitHub-Type: pull_request X-GitHub-Url: https://github.com/postgresql-interfaces/psqlodbc/pull/107 Content-Type: text/plain; charset=utf-8 ## Summary A previous PR (https://github.com/postgresql-interfaces/psqlodbc/pull/105) replaced the instances of memset with memset_s or SecureZeroMemory because there's a chance that compiler may remove these calls during optimization. However, this PR will break builds with compilers that do not have memset_s. `memset_s` was introduced in C11, but it is flagged as optional and many compilers like GCC do not implement this. For the time being, this commit will re-introduce memset if `memset_s` is not implemented in the compiler by checking `__STDC_LIB_EXT1__` and defining `__STDC_WANT_LIB_EXT1__` before the needed imports. (reference: https://en.cppreference.com/w/c/string/byte/memset). This commit also removes the changes in the unit test. `memset` should be safe in the unit tests. (previous implementaiton caused 2 unit tests to fail, (`not ok 9 - result-conversions test output differs``not ok 40 - diagnostic test`) because it used memset with a non-zero value. ## Testing Built on: - Mac M2 - Windows - Linux Ubuntu 24 Ran regression test on Windows and tests had same results as mainline prior to 105