Convert char* to text for text_substr call

pull/6753/head
Gokhan Gulbiz 2023-03-20 09:40:08 +03:00
parent df3ad5c4f6
commit 34e1dafb18
No known key found for this signature in database
GPG Key ID: 608EF06B6BD1B45B
1 changed files with 4 additions and 4 deletions

View File

@ -646,9 +646,9 @@ ExtractTopComment(const char *inputString)
if (commentEndCharsIndex > commentStartCharsLength) if (commentEndCharsIndex > commentStartCharsLength)
{ {
Datum substringTextDatum = DirectFunctionCall3(text_substr, PointerGetDatum( Datum substringTextDatum = DirectFunctionCall3(text_substr, PointerGetDatum(
inputString), cstring_to_text(inputString)),
Int32GetDatum( Int32GetDatum(
commentStartCharsLength), commentStartCharsLength + 1),
Int32GetDatum( Int32GetDatum(
commentEndCharsIndex - commentEndCharsIndex -
commentStartCharsLength)); commentStartCharsLength));
@ -666,7 +666,7 @@ static char *
EscapeCommentChars(const char *str) EscapeCommentChars(const char *str)
{ {
int originalStringLength = strlen(str); int originalStringLength = strlen(str);
char *escapedString = (char *) palloc(originalStringLength * 2 + 1); char *escapedString = (char *) palloc0((originalStringLength * 2 + 1) * sizeof(char));
int escapedStringIndex = 0; int escapedStringIndex = 0;
for (int originalStringIndex = 0; originalStringIndex < originalStringLength; for (int originalStringIndex = 0; originalStringIndex < originalStringLength;
@ -689,7 +689,7 @@ static char *
UnescapeCommentChars(const char *str) UnescapeCommentChars(const char *str)
{ {
int originalStringLength = strlen(str); int originalStringLength = strlen(str);
char *unescapedString = (char *) palloc(originalStringLength + 1); char *unescapedString = (char *) palloc0((originalStringLength + 1) * sizeof(char));
int unescapedStringIndex = 0; int unescapedStringIndex = 0;
for (int originalStringindex = 0; originalStringindex < originalStringLength; for (int originalStringindex = 0; originalStringindex < originalStringLength;