blob: 55cb950b0bfe787c57fe1caa4d3f524e697ac89d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
%module string_simple
%newobject copy_str;
%inline %{
#include <stdlib.h>
#include <string.h>
const char* copy_str(const char* str) {
size_t len = strlen(str);
char* newstring = (char*) malloc(len + 1);
strcpy(newstring, str);
return newstring;
}
%}
|