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
+2 -2
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;