boot.dev lesson answers for the course: Learn Memory Management in C
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

11 lines
270 B

#include <stdlib.h>
#include "snekobject.h"
snek_object_t *new_snek_integer(int value) {
snek_object_t *number = (snek_object_t *)malloc(sizeof(snek_object_t));
if (number == NULL) return NULL;
number->kind = INTEGER;
number->data.v_int = value;
return number;
}