[libc-commits] [libc] [libc][stdlib] Implement setenv() with environment management infrastructure (PR #163018)

via libc-commits libc-commits at lists.llvm.org
Fri Dec 19 03:27:02 PST 2025


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff origin/main HEAD --extensions h,cpp -- libc/src/stdlib/environ_internal.cpp libc/src/stdlib/environ_internal.h libc/src/stdlib/linux/setenv.cpp libc/src/stdlib/setenv.h libc/test/integration/src/stdlib/setenv_test.cpp --diff_from_common_commit
``````````

:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/libc/src/stdlib/environ_internal.cpp b/libc/src/stdlib/environ_internal.cpp
index 08319e2a7..fe1ca15f7 100644
--- a/libc/src/stdlib/environ_internal.cpp
+++ b/libc/src/stdlib/environ_internal.cpp
@@ -120,9 +120,8 @@ bool EnvironmentManager::ensure_capacity(size_t needed) {
   if (!new_storage)
     return false;
 
-  EnvStringOwnership *new_ownership =
-      reinterpret_cast<EnvStringOwnership *>(realloc(
-          ownership, sizeof(EnvStringOwnership) * (new_capacity + 1)));
+  EnvStringOwnership *new_ownership = reinterpret_cast<EnvStringOwnership *>(
+      realloc(ownership, sizeof(EnvStringOwnership) * (new_capacity + 1)));
   if (!new_ownership) {
     // If ownership realloc fails, we still have the old storage in new_storage
     // which was successfully reallocated. We need to restore or handle this.

``````````

</details>


https://github.com/llvm/llvm-project/pull/163018


More information about the libc-commits mailing list