We need to malloc() the size of the structure, not the pointer.
This commit is contained in:
parent
abca15d2be
commit
155e03e42c
@ -6,7 +6,7 @@
|
|||||||
struct card *initialize_card() {
|
struct card *initialize_card() {
|
||||||
struct card *card = NULL;
|
struct card *card = NULL;
|
||||||
|
|
||||||
card = malloc(sizeof(card));
|
card = malloc(sizeof(*card));
|
||||||
|
|
||||||
card->frame = initialize_frame();
|
card->frame = initialize_frame();
|
||||||
card->value = NO_VALUE;
|
card->value = NO_VALUE;
|
||||||
|
@ -22,7 +22,7 @@ void init_curses() {
|
|||||||
char *card_suit(enum suit suit) {
|
char *card_suit(enum suit suit) {
|
||||||
char *card_suit;
|
char *card_suit;
|
||||||
|
|
||||||
card_suit = malloc(5 * sizeof(card_suit));
|
card_suit = malloc(5 * sizeof(*card_suit));
|
||||||
|
|
||||||
switch(suit) {
|
switch(suit) {
|
||||||
case DIAMONDS: strcpy(card_suit, DIAMONDS_SYMBOL); break;
|
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(enum value value) {
|
||||||
char *card_value;
|
char *card_value;
|
||||||
|
|
||||||
card_value = malloc(2 * sizeof(card_value));
|
card_value = malloc(2 * sizeof(*card_value));
|
||||||
|
|
||||||
switch(value) {
|
switch(value) {
|
||||||
case TWO: card_value = "2"; break;
|
case TWO: card_value = "2"; break;
|
||||||
|
@ -13,7 +13,7 @@ WINDOW *initialize_shape() {
|
|||||||
struct frame *initialize_frame() {
|
struct frame *initialize_frame() {
|
||||||
struct frame *frame = NULL;
|
struct frame *frame = NULL;
|
||||||
|
|
||||||
frame = malloc(sizeof(frame));
|
frame = malloc(sizeof(*frame));
|
||||||
|
|
||||||
frame->shape = initialize_shape();
|
frame->shape = initialize_shape();
|
||||||
frame->height = FRAME_HEIGHT;
|
frame->height = FRAME_HEIGHT;
|
||||||
|
Loading…
Reference in New Issue
Block a user