MCPcopy Create free account
hub / github.com/XUANXUQAQ/File-Engine / utf8JavaByteArrayToUtf8Bytes

Function utf8JavaByteArrayToUtf8Bytes

C++/sqliteJDBC/sqliteJDBC/NativeDB.c:139–167  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

137}
138
139static void utf8JavaByteArrayToUtf8Bytes(JNIEnv *env, jbyteArray utf8bytes, char** bytes, int* nbytes)
140{
141 jsize utf8bytes_length;
142 char* buf;
143
144 *bytes = NULL;
145 if (nbytes) *nbytes = 0;
146
147 if (!utf8bytes)
148 {
149 return;
150 }
151
152 utf8bytes_length = (*env)->GetArrayLength(env, (jarray) utf8bytes);
153
154 buf = (char*) malloc(utf8bytes_length + 1);
155 if (!buf)
156 {
157 throwex_outofmemory(env);
158 return;
159 }
160
161 (*env)->GetByteArrayRegion(env, utf8bytes, 0, utf8bytes_length, (jbyte*)buf);
162
163 buf[utf8bytes_length] = '\0';
164
165 *bytes = buf;
166 if (nbytes) *nbytes = (int) utf8bytes_length;
167}
168
169static jbyteArray stringToUtf8ByteArray(JNIEnv *env, jstring str)
170{

Calls 3

throwex_outofmemoryFunction · 0.85
GetArrayLengthMethod · 0.45
GetByteArrayRegionMethod · 0.45

Tested by

no test coverage detected