We need to malloc() the size of the structure, not the pointer.

This commit is contained in:
Murilo Soares Pereira 2010-04-04 21:00:36 -03:00
parent abca15d2be
commit 155e03e42c
3 changed files with 4 additions and 4 deletions

View File

@ -6,7 +6,7 @@
struct card *initialize_card() {
struct card *card = NULL;
card = malloc(sizeof(card));
card = malloc(sizeof(*card));
card->frame = initialize_frame();
card->value = NO_VALUE;

View File

@ -22,7 +22,7 @@ void init_curses() {
char *card_suit(enum suit suit) {
char *card_suit;
card_suit = malloc(5 * sizeof(card_suit));
card_suit = malloc(5 * sizeof(*card_suit));
switch(suit) {
case DIAMONDS: strcpy(card_suit, DIAMONDS_SYMBOL); break;
@ -38,7 +38,7 @@ char *card_suit(enum suit suit) {
char *card_value(enum value value) {
char *card_value;
card_value = malloc(2 * sizeof(card_value));
card_value = malloc(2 * sizeof(*card_value));
switch(value) {
case TWO: card_value = "2"; break;

View File

@ -13,7 +13,7 @@ WINDOW *initialize_shape() {
struct frame *initialize_frame() {
struct frame *frame = NULL;
frame = malloc(sizeof(frame));
frame = malloc(sizeof(*frame));
frame->shape = initialize_shape();
frame->height = FRAME_HEIGHT;