[Go] Fix Go multimap example to use Swig_AllocateString and swigCopyString.
This commit is contained in:
parent
48263f4802
commit
e044dc4405
1 changed files with 7 additions and 2 deletions
|
|
@ -74,16 +74,21 @@ extern int count(char *bytes, int len, char c);
|
||||||
%}
|
%}
|
||||||
|
|
||||||
/* Return the mutated string as a modified element in the array. */
|
/* Return the mutated string as a modified element in the array. */
|
||||||
%typemap(argout) (char *str, int len)
|
%typemap(argout,fragment="AllocateString") (char *str, int len)
|
||||||
%{
|
%{
|
||||||
{
|
{
|
||||||
_gostring_ *a;
|
_gostring_ *a;
|
||||||
|
|
||||||
a = (_gostring_*) $input.array;
|
a = (_gostring_*) $input.array;
|
||||||
a[0] = _swig_makegostring($1, $2);
|
a[0] = Swig_AllocateString($1, $2);
|
||||||
}
|
}
|
||||||
%}
|
%}
|
||||||
|
|
||||||
|
%typemap(goargout,fragment="CopyString") (char *str, int len)
|
||||||
|
%{
|
||||||
|
$input[0] = swigCopyString($input[0])
|
||||||
|
%}
|
||||||
|
|
||||||
%typemap(freearg) (char *str, int len)
|
%typemap(freearg) (char *str, int len)
|
||||||
%{
|
%{
|
||||||
free($1);
|
free($1);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue