Now I don't understand why malloc isn't working

typedef union
{
int64_t int_d;
double number_d;
} Token_data;

typedef struct
{
Token_type type;
Token_data data;
} Token_t;

Token_t *my_token = (Token*) malloc(sizeof(Token_t))

@matrix

If it’s crashing on malloc that sounds like it’s not properly linked tbh. Do you have access to a debugger?

How are you building and running it?

Follow

@ademan I do. That's how I know it's that line

· · Web · 1 · 0 · 0

@matrix

What output do you get if you put this line before your malloc call?

printf("malloc = %p\n", malloc);

@matrix (alternatively, use your debugger to inspect the actual function address, if you know how, I figured this was an easier route though hah)

Sign in to participate in the conversation
Game Liberty Mastodon

Mainly gaming/nerd instance for people who value free speech. Everyone is welcome.