mirror of
https://github.com/yshui/picom.git
synced 2024-11-11 13:51:02 -05:00
Use strncpy for string_utils functions
Also removed mstrjoin3 since it's not used. Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
parent
61d8e7825f
commit
2eb8cf961e
2 changed files with 20 additions and 21 deletions
|
@ -561,7 +561,7 @@ glx_init_blur(session_t *ps) {
|
|||
const char *texture_func = (use_texture_rect ?
|
||||
"texture2DRect": "texture2D");
|
||||
const char *shader_add = FRAG_SHADER_BLUR_ADD;
|
||||
char *extension = strdup("");
|
||||
char *extension = NULL;
|
||||
if (use_texture_rect)
|
||||
mstrextend(&extension, "#extension GL_ARB_texture_rectangle : require\n");
|
||||
if (ps->o.glx_use_gpushader4) {
|
||||
|
|
|
@ -11,33 +11,32 @@
|
|||
* Allocate the space and join two strings.
|
||||
*/
|
||||
char *mstrjoin(const char *src1, const char *src2) {
|
||||
auto str = ccalloc(strlen(src1)+strlen(src2)+1, char);
|
||||
auto len1 = strlen(src1);
|
||||
auto len2 = strlen(src2);
|
||||
auto len = len1 + len2 + 1;
|
||||
auto str = ccalloc(len, char);
|
||||
|
||||
strcpy(str, src1);
|
||||
strcat(str, src2);
|
||||
strncpy(str, src1, len1);
|
||||
strncpy(str + len1, src2, len2);
|
||||
str[len - 1] = '\0';
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
/**
|
||||
* Allocate the space and join two strings;
|
||||
*/
|
||||
char *
|
||||
mstrjoin3(const char *src1, const char *src2, const char *src3) {
|
||||
auto str = ccalloc(strlen(src1)+strlen(src2)+strlen(src3)+1, char);
|
||||
|
||||
strcpy(str, src1);
|
||||
strcat(str, src2);
|
||||
strcat(str, src3);
|
||||
|
||||
return str;
|
||||
return str;
|
||||
}
|
||||
|
||||
/**
|
||||
* Concatenate a string on heap with another string.
|
||||
*/
|
||||
void mstrextend(char **psrc1, const char *src2) {
|
||||
*psrc1 = crealloc(*psrc1, (*psrc1 ? strlen(*psrc1) : 0)+strlen(src2)+1);
|
||||
if (!*psrc1) {
|
||||
*psrc1 = strdup(src2);
|
||||
return;
|
||||
}
|
||||
|
||||
strcat(*psrc1, src2);
|
||||
auto len1 = strlen(*psrc1);
|
||||
auto len2 = strlen(src2);
|
||||
auto len = len1 + len2 + 1;
|
||||
*psrc1 = crealloc(*psrc1, len);
|
||||
|
||||
strncpy(*psrc1 + len1, src2, len2);
|
||||
(*psrc1)[len - 1] = '\0';
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue