From d62aa8889726c962f2adc45d821390160b28972d Mon Sep 17 00:00:00 2001 From: Kors Chen <0x6ace@gmail.com> Date: Tue, 23 Apr 2024 17:42:49 +0800 Subject: [PATCH 1/3] argc --- ch04-process-memory-structure/ExtremeC_examples_chapter4_5.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ch04-process-memory-structure/ExtremeC_examples_chapter4_5.c b/ch04-process-memory-structure/ExtremeC_examples_chapter4_5.c index b8c74f1..f6743f3 100644 --- a/ch04-process-memory-structure/ExtremeC_examples_chapter4_5.c +++ b/ch04-process-memory-structure/ExtremeC_examples_chapter4_5.c @@ -1,6 +1,6 @@ // File name: ExtremeC_exampels_chapter4_5.c // Description: Example 4.5 -int main(int agrc, char** argv) { +int main(int argc, char** argv) { return 0; } From bdeeab15496e45902f1f857de6cd52940f74cb8c Mon Sep 17 00:00:00 2001 From: Kors Chen <0x6ace@gmail.com> Date: Wed, 24 Apr 2024 10:21:02 +0800 Subject: [PATCH 2/3] macOS vmmap --- ch05-stack-and-heap/ExtremeC_examples_chapter5_3.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/ch05-stack-and-heap/ExtremeC_examples_chapter5_3.c b/ch05-stack-and-heap/ExtremeC_examples_chapter5_3.c index 153acf4..9452fba 100644 --- a/ch05-stack-and-heap/ExtremeC_examples_chapter5_3.c +++ b/ch05-stack-and-heap/ExtremeC_examples_chapter5_3.c @@ -4,6 +4,10 @@ #include // For printf function #include // For C library's heap memory functions +#if defined(__APPLE__) && defined(__MACH__) + #include +#endif + void print_mem_maps() { #ifdef __linux__ FILE* fd = fopen("/proc/self/maps", "r"); @@ -17,6 +21,11 @@ void print_mem_maps() { printf("> %s", line); } fclose(fd); +#elif defined(__APPLE__) && defined(__MACH__) + char command[256]; + pid_t pid = getpid(); + sprintf(command, "vmmap %d", pid); + system(command); #endif } From db11b65ff8e2303259a3ae988cf11a4462817ac0 Mon Sep 17 00:00:00 2001 From: Kors Chen <0x6ace@gmail.com> Date: Wed, 24 Apr 2024 17:22:38 +0800 Subject: [PATCH 3/3] chapter5_6 error fixed --- ch05-stack-and-heap/ExtremeC_examples_chapter5_6.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ch05-stack-and-heap/ExtremeC_examples_chapter5_6.c b/ch05-stack-and-heap/ExtremeC_examples_chapter5_6.c index 71686d0..873cd97 100644 --- a/ch05-stack-and-heap/ExtremeC_examples_chapter5_6.c +++ b/ch05-stack-and-heap/ExtremeC_examples_chapter5_6.c @@ -58,8 +58,8 @@ int not_friendly_sum(int* matrix, int rows, int columns) { int main(int argc, char** argv) { if (argc < 4) { - printf("Usage: %s [print|friendly-sum|not-friendly-sum] "); - printf("[number-of-rows] [number-of-columns]\n", argv[0]); + printf("Usage: %s [print|friendly-sum|not-friendly-sum] ", argv[0]); + printf("[number-of-rows] [number-of-columns]\n"); exit(1); } char* operation = argv[1];