diff --git a/CHANGES.current b/CHANGES.current index 55acf322b..cda378170 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,9 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.4.0 (in progress) =========================== +2025-07-28: erezgeva + #2937 Add missing support for (size_t LENGTH, char *STRING) multi-argument typemaps. + 2025-07-23: jim-easterbrook [Python] #3218 Added weakref support to builtin wrappers. diff --git a/Doc/Manual/Library.html b/Doc/Manual/Library.html index 983faa6a0..a01898369 100644 --- a/Doc/Manual/Library.html +++ b/Doc/Manual/Library.html @@ -940,7 +940,7 @@ The (char *STRING, int LENGTH) multi-argument typemap is also available

-We also support passing parameters in reverse order +SWIG also supports passing these parameters but in reverse order, for example:

@@ -953,7 +953,7 @@ size_t parity(size_t len, char *str, size_t initial);

The usage from target language will be identical. -In the wrapper function, the passed string will be expanded to a length parameter and pointer. +In the wrapper function, the supplied string will be expanded to a length parameter and pointer.

12.3.3 Using %newobject to release memory

diff --git a/Lib/csharp/csharp.swg b/Lib/csharp/csharp.swg index 9f0bb4411..b17c7abc8 100644 --- a/Lib/csharp/csharp.swg +++ b/Lib/csharp/csharp.swg @@ -1142,8 +1142,7 @@ SWIGEXPORT char *SWIGSTDCALL SWIG_csharp_string_str(SWIG_csharp_string *p) { %typemap(imtype) (const char *STRING, size_t LENGTH) "global::System.IntPtr" %typemap(csin) (const char *STRING, size_t LENGTH) "$modulePINVOKE.SWIGStringWithLengthHelper.SWIG_csharp_string_to_c($csinput)" %typemap(in, canthrow=1, fragment="SWIG_csharp_string") (const char *STRING, size_t LENGTH) { - SWIG_csharp_string *p; - p = (SWIG_csharp_string *)$input; + SWIG_csharp_string *p = (SWIG_csharp_string *)$input; if (p) { $1 = ($1_ltype)p->str; $2 = ($2_ltype)p->size; /* We use number of bytes */ @@ -1153,8 +1152,7 @@ SWIGEXPORT char *SWIGSTDCALL SWIG_csharp_string_str(SWIG_csharp_string *p) { } } %typemap(freearg, fragment="SWIG_csharp_string") (const char *STRING, size_t LENGTH) { - SWIG_csharp_string *p; - p = (SWIG_csharp_string *)$input; + SWIG_csharp_string *p = (SWIG_csharp_string *)$input; if (p) { free(p->str); free(p); @@ -1184,8 +1182,7 @@ SWIGEXPORT char *SWIGSTDCALL SWIG_csharp_string_str(SWIG_csharp_string *p) { %typemap(imtype) (size_t LENGTH, const char *STRING) "global::System.IntPtr" %typemap(csin) (size_t LENGTH, const char *STRING) "$modulePINVOKE.SWIGStringWithLengthHelper.SWIG_csharp_string_to_c($csinput)" %typemap(in, canthrow=1, fragment="SWIG_csharp_string") (size_t LENGTH, const char *STRING) { - SWIG_csharp_string *p; - p = (SWIG_csharp_string *)$input; + SWIG_csharp_string *p = (SWIG_csharp_string *)$input; if (p) { $2 = ($2_ltype)p->str; $1 = ($1_ltype)p->size; /* We use number of bytes */ @@ -1194,16 +1191,13 @@ SWIGEXPORT char *SWIGSTDCALL SWIG_csharp_string_str(SWIG_csharp_string *p) { $2 = 0; } } -%typemap(freearg, fragment="SWIG_csharp_string") (size_t LENGTH, const char *STRING) %{ - { - SWIG_csharp_string *p; - p = (SWIG_csharp_string *)$input; - if (p) { - free(p->str); - free(p); - } +%typemap(freearg, fragment="SWIG_csharp_string") (size_t LENGTH, const char *STRING) { + SWIG_csharp_string *p = (SWIG_csharp_string *)$input; + if (p) { + free(p->str); + free(p); } -%} +} %typemap(directorin) (size_t LENGTH, const char *STRING) %{ if ($2 && $1 > 0) { $input = malloc(sizeof(SWIG_csharp_string));