From 4c4852fd37f88439880633e689bbd42ce7dd8cb8 Mon Sep 17 00:00:00 2001 From: Luka Teras Date: Fri, 3 Jan 2025 20:22:27 +0000 Subject: [PATCH] `README.md`: remove dynamic allocation from the example --- README.md | 5 ++--- openbsd/README.md | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index d0d4c1a..73d9de0 100644 --- a/README.md +++ b/README.md @@ -16,13 +16,12 @@ A tiny, secure, URL-friendly unique string ID generator for C. #include int main() { - char *id = calloc(NANOIDLEN + 1, 1); + char id[NANOIDLEN + 1] = ""; - if (!id || nanoidgen(id, NANOIDLEN)) + if (nanoidgen(id, NANOIDLEN)) return EXIT_FAILURE; puts(id); - free(id); } ``` diff --git a/openbsd/README.md b/openbsd/README.md index e305371..2f4ce1e 100644 --- a/openbsd/README.md +++ b/openbsd/README.md @@ -16,13 +16,12 @@ A tiny, secure, URL-friendly unique string ID generator for C. #include int main() { - char *id = calloc(NANOIDLEN + 1, 1); + char id[NANOIDLEN + 1] = ""; - if (!id || nanoidgen(id, NANOIDLEN)) + if (nanoidgen(id, NANOIDLEN)) return EXIT_FAILURE; puts(id); - free(id); } ```