mirror of
https://github.com/idris-lang/Idris2.git
synced 2024-11-23 22:22:07 +03:00
28 lines
440 B
C
28 lines
440 B
C
#include <stdlib.h>
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
|
|
typedef struct {
|
|
int val;
|
|
char* str;
|
|
} Stuff;
|
|
|
|
Stuff* mkThing() {
|
|
static int num = 0;
|
|
Stuff* x = malloc(sizeof(Stuff));
|
|
x->val = num++;
|
|
x->str = malloc(20);
|
|
strcpy(x->str,"Hello");
|
|
return x;
|
|
}
|
|
|
|
char* getStr(Stuff* x) {
|
|
return x->str;
|
|
}
|
|
|
|
void freeThing(Stuff* x) {
|
|
printf("Freeing %d %s\n", x->val, x->str);
|
|
free(x->str);
|
|
free(x);
|
|
}
|