Skip to content

Instantly share code, notes, and snippets.

@kaneshin
Created February 23, 2015 07:51
Show Gist options
  • Select an option

  • Save kaneshin/594639a55a98db879dfe to your computer and use it in GitHub Desktop.

Select an option

Save kaneshin/594639a55a98db879dfe to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <stdlib.h>
struct Some {
int *num;
};
struct Some *
alloc_some(int n) {
struct Some *some = (struct Some *)malloc(n * sizeof(struct Some));
some->num = (int *)malloc(sizeof(int));
return some;
}
int
main(int argc, char* argv[])
{
struct Some *some = (struct Some *)malloc(sizeof(struct Some));
printf("%x\n", some);
printf("%x\n", some->num);
struct Some *foo = alloc_some(1);
printf("%x\n", foo);
printf("%x\n", foo->num);
return 0;
}
@kaneshin

Copy link
Copy Markdown
Author

40404ba0
0
40404bb0
40404bc0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment