Created
September 20, 2012 17:17
-
-
Save reagent/3757148 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <string.h> | |
struct Person { | |
char *name; | |
}; | |
int main(int argc, char *argv[]) | |
{ | |
int i = 0; | |
char *name = "Patrick"; | |
char *other_name = strdup(name); | |
char initial = 'R'; | |
struct Person patrick; | |
patrick.name = "Patrick"; | |
printf("Integer is at location: %p\n", &i); | |
printf("String is at location: %p\n", name); | |
printf("Duplicated string is at location: %p\n", other_name); | |
printf("Character is at location: %p\n", &initial); | |
printf("name is at location: %p\n", patrick.name); | |
printf("&name is at location: %p\n", &patrick.name); | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Integer is at location: 0x7fff5fbff028 | |
String is at location: 0x100000e78 | |
Duplicated string is at location: 0x100100080 | |
Character is at location: 0x7fff5fbff02f | |
name is at location: 0x100000e78 | |
&name is at location: 0x7fff5fbff010 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
==28070== Memcheck, a memory error detector | |
==28070== Copyright (C) 2002-2010, and GNU GPL'd, by Julian Seward et al. | |
==28070== Using Valgrind-3.6.1 and LibVEX; rerun with -h for copyright info | |
==28070== Command: ./strings | |
==28070== | |
Integer is at location: 0x7fff5fbff608 | |
String is at location: 0x100000e78 | |
Duplicated string is at location: 0x10027e0e0 | |
Character is at location: 0x7fff5fbff60f | |
name is at location: 0x100000e78 | |
&name is at location: 0x7fff5fbff5f0 | |
==28070== | |
==28070== HEAP SUMMARY: | |
==28070== in use at exit: 4,192 bytes in 3 blocks | |
==28070== total heap usage: 3 allocs, 0 frees, 4,192 bytes allocated | |
==28070== | |
==28070== LEAK SUMMARY: | |
==28070== definitely lost: 8 bytes in 1 blocks | |
==28070== indirectly lost: 0 bytes in 0 blocks | |
==28070== possibly lost: 0 bytes in 0 blocks | |
==28070== still reachable: 4,184 bytes in 2 blocks | |
==28070== suppressed: 0 bytes in 0 blocks | |
==28070== Rerun with --leak-check=full to see details of leaked memory | |
==28070== | |
==28070== For counts of detected and suppressed errors, rerun with: -v | |
==28070== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment