mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-01-31 11:37:35 +00:00
68c7c9c1e0
- Use good ELF technique in cosmo_dlopen() - Make strerror() conform more to other libc impls - Introduce __clear_cache() and use it in cosmo_dlopen() - Remove libc/fmt/fmt.h header (trying to kill off LIBC_FMT)
36 lines
1.4 KiB
C
36 lines
1.4 KiB
C
#if 0
|
|
/*─────────────────────────────────────────────────────────────────╗
|
|
│ To the extent possible under law, Justine Tunney has waived │
|
|
│ all copyright and related or neighboring rights to this file, │
|
|
│ as it is written in the following disclaimers: │
|
|
│ • http://unlicense.org/ │
|
|
│ • http://creativecommons.org/publicdomain/zero/1.0/ │
|
|
╚─────────────────────────────────────────────────────────────────*/
|
|
#endif
|
|
#include "libc/calls/calls.h"
|
|
#include "libc/log/check.h"
|
|
#include "libc/mem/mem.h"
|
|
#include "libc/stdio/append.h"
|
|
#include "libc/str/str.h"
|
|
|
|
/**
|
|
* @fileoverview Fast Growable Strings Tutorial
|
|
*/
|
|
|
|
int main(int argc, char *argv[]) {
|
|
char *b = 0;
|
|
appendf(&b, "hello "); // guarantees nul terminator
|
|
CHECK_EQ(6, strlen(b));
|
|
CHECK_EQ(6, appendz(b).i);
|
|
appendf(&b, " world\n");
|
|
CHECK_EQ(13, strlen(b));
|
|
CHECK_EQ(13, appendz(b).i);
|
|
appendd(&b, "\0", 1); // supports binary
|
|
CHECK_EQ(13, strlen(b));
|
|
CHECK_EQ(14, appendz(b).i);
|
|
appendf(&b, "%d arg%s\n", argc, argc == 1 ? "" : "s");
|
|
appendf(&b, "%s\n", "have a nice day");
|
|
write(1, b, appendz(b).i);
|
|
free(b);
|
|
return 0;
|
|
}
|