rkavanap commented on a change in pull request #11049:
URL: https://github.com/apache/arrow/pull/11049#discussion_r741133878



##########
File path: cpp/src/gandiva/precompiled/string_ops.cc
##########
@@ -1762,6 +1762,41 @@ const char* replace_utf8_utf8_utf8(gdv_int64 context, 
const char* text,
                                              out_len);
 }
 
+// Returns the quoted string (Includes escape character for any single quotes)
+// E.g. DONT  -> 'DONT'
+//      DON'T -> 'DON\'T'
+FORCE_INLINE
+const char* quote_utf8(gdv_int64 context, const char* in, gdv_int32 in_len,
+                       gdv_int32* out_len) {
+  if (in_len <= 0) {
+    *out_len = 0;
+    return "";
+  }
+  // try to allocate double size output string (worst case)
+  auto out = reinterpret_cast<char*>(gdv_fn_context_arena_malloc(context, 
in_len * 2));

Review comment:
       shouldn't this be in_len * 2 + 2 for the worst case of the loop? or does 
in_len include the null termination of the string? Actually I see at least in 
the unit test that in_len does not include the null_termination of the string.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to