feat: add calltoc

This commit is contained in:
2022-12-30 13:04:31 +08:00
parent b98542fff3
commit 060c6b2263
6 changed files with 102 additions and 0 deletions

30
__ffi/calltoc/myc.c Normal file
View File

@@ -0,0 +1,30 @@
#include <stdio.h>
#include <stdlib.h>
char* hello() {
char* ptr = (char*)malloc(13);
if (ptr == NULL) {
return ptr;
}
ptr[0] = 'H';
ptr[1] = 'e';
ptr[2] = 'l';
ptr[3] = 'l';
ptr[4] = 'o';
ptr[5] = ' ';
ptr[6] = 'w';
ptr[7] = 'o';
ptr[8] = 'r';
ptr[9] = 'l';
ptr[10] = 'd';
ptr[11] = '!';
ptr[12] = '\0';
return ptr;
}
void goodbye(char* ptr) {
if (ptr != NULL) {
free(ptr);
}
}