Make GetStringTableData native binary-safe (#1232)

Replace StringToLocalUTF8 with LocalToString and memcpy to make this binary compatible and update the documentation.
This commit is contained in:
thewavelength
2020-04-14 17:51:39 +01:00
committed by GitHub
parent 1d98c3a782
commit 25462071df
2 changed files with 19 additions and 11 deletions
+3 -4
View File
@@ -119,9 +119,9 @@ native int GetStringTableDataLength(int tableidx, int stringidx);
*
* @param tableidx A string table index.
* @param stringidx A string index.
* @param userdata Buffer to store the user data. This will be set to "" if there is no user data.
* @param userdata Buffer to store the user data. This will be set to "" if there is no user data
* @param maxlength Maximum length of string buffer.
* @return Number of bytes written to the buffer (UTF-8 safe).
* @return Number of bytes written to the buffer (binary safe, includes the null terminator).
* @error Invalid string table index or string index.
*/
native int GetStringTableData(int tableidx, int stringidx, char[] userdata, int maxlength);
@@ -133,10 +133,9 @@ native int GetStringTableData(int tableidx, int stringidx, char[] userdata, int
* @param stringidx A string index.
* @param userdata User data string that will be set.
* @param length Length of user data string. This should include the null terminator.
* @return Number of bytes written to the buffer (UTF-8 safe).
* @error Invalid string table index or string index.
*/
native int SetStringTableData(int tableidx, int stringidx, const char[] userdata, int length);
native void SetStringTableData(int tableidx, int stringidx, const char[] userdata, int length);
/**
* Adds a string to a given string table.