-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcinterop.c
More file actions
32 lines (27 loc) · 701 Bytes
/
cinterop.c
File metadata and controls
32 lines (27 loc) · 701 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
void ll_puts(int8_t *s) {
puts((char *)s);
}
int8_t* ll_strcat(int8_t* s1, int8_t* s2) {
int l1 = strlen((char*)s1);
int l2 = strlen((char*)s2);
char* buf = (char*)calloc(l1 + l2 + 1, sizeof(char));
strncpy(buf, (char*)s1, l1);
strncpy(buf + l1, (char*)s2, l2+1);
return (int8_t*) buf;
}
int64_t ll_callback(int64_t (*fun)(int64_t, int64_t)) {
int64_t x = 19L;
return fun(x, x);
}
int8_t* ll_ltoa(int64_t i) {
char* buf = (char*)calloc(20, sizeof(char));
snprintf((char *)buf, 20, "%ld", (long)i);
return (int8_t *)buf;
}
void *ll_malloc(int64_t n, int64_t size) {
return calloc(n, size);
}