Cleanup: remove use of strcat

While these uses seemed safe, strcat is error prone enough that other
functions are preferable.
This commit is contained in:
Campbell Barton
2023-05-24 17:43:50 +10:00
parent a4217d8a71
commit 4ac66828cf
4 changed files with 11 additions and 22 deletions

View File

@@ -38,6 +38,7 @@
#include "BKE_material.h"
#include "BKE_modifier.h"
#include "BKE_object.h"
#include "BKE_screen.h"
#include "BKE_shrinkwrap.h"
#include "DEG_depsgraph.h"
@@ -447,9 +448,7 @@ const GpencilModifierTypeInfo *BKE_gpencil_modifier_get_info(GpencilModifierType
void BKE_gpencil_modifierType_panel_id(GpencilModifierType type, char *r_idname)
{
const GpencilModifierTypeInfo *mti = BKE_gpencil_modifier_get_info(type);
strcpy(r_idname, GPENCIL_MODIFIER_TYPE_PANEL_PREFIX);
strcat(r_idname, mti->name);
BLI_string_join(r_idname, BKE_ST_MAXNAME, GPENCIL_MODIFIER_TYPE_PANEL_PREFIX, mti->name);
}
void BKE_gpencil_modifier_panel_expand(GpencilModifierData *md)

View File

@@ -27,6 +27,7 @@
#include "BKE_lib_id.h"
#include "BKE_lib_query.h"
#include "BKE_object.h"
#include "BKE_screen.h"
#include "BKE_shader_fx.h"
#include "DEG_depsgraph.h"
@@ -156,9 +157,7 @@ bool BKE_shaderfx_is_nonlocal_in_liboverride(const Object *ob, const ShaderFxDat
void BKE_shaderfxType_panel_id(ShaderFxType type, char *r_idname)
{
const ShaderFxTypeInfo *fxi = BKE_shaderfx_get_info(type);
strcpy(r_idname, SHADERFX_TYPE_PANEL_PREFIX);
strcat(r_idname, fxi->name);
BLI_string_join(r_idname, BKE_ST_MAXNAME, SHADERFX_TYPE_PANEL_PREFIX, fxi->name);
}
void BKE_shaderfx_panel_expand(ShaderFxData *fx)

View File

@@ -22,6 +22,7 @@
#include "BLI_linklist.h"
#include "BLI_string.h"
#include "BLI_string_utils.h"
#include "BLI_virtual_array.hh"
#include "PIL_time.h"
@@ -251,16 +252,9 @@ static GPUShader *get_patch_evaluation_shader(int shader_type)
/* Merge OpenSubdiv library code with our own library code. */
const char *patch_basis_source = openSubdiv_getGLSLPatchBasisSource();
const char *subdiv_lib_code = datatoc_common_subdiv_lib_glsl;
char *library_code = static_cast<char *>(
MEM_mallocN(strlen(patch_basis_source) + strlen(subdiv_lib_code) + 1,
"subdiv patch evaluation library code"));
library_code[0] = '\0';
strcat(library_code, patch_basis_source);
strcat(library_code, subdiv_lib_code);
char *library_code = BLI_string_joinN(patch_basis_source, subdiv_lib_code);
g_subdiv_shaders[shader_type] = GPU_shader_create_compute(
compute_code, library_code, defines, get_shader_name(shader_type));
MEM_freeN(library_code);
}

View File

@@ -32,6 +32,7 @@
#include "BLI_rect.h"
#include "BLI_string.h"
#include "BLI_string_search.h"
#include "BLI_string_utils.h"
#include "BLI_timecode.h"
#include "BLI_utildefines.h"
@@ -2408,7 +2409,7 @@ static void set_constraint_expand_flag(const bContext * /*C*/, Panel *panel, sho
* \note Constraint panel types are assumed to be named with the struct name field
* concatenated to the defined prefix.
*/
static void object_constraint_panel_id(void *md_link, char *r_name)
static void object_constraint_panel_id(void *md_link, char *r_idname)
{
bConstraint *con = (bConstraint *)md_link;
const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_from_type(con->type);
@@ -2417,12 +2418,10 @@ static void object_constraint_panel_id(void *md_link, char *r_name)
if (cti == nullptr) {
return;
}
strcpy(r_name, CONSTRAINT_TYPE_PANEL_PREFIX);
strcat(r_name, cti->structName);
BLI_string_join(r_idname, BKE_ST_MAXNAME, CONSTRAINT_TYPE_PANEL_PREFIX, cti->structName);
}
static void bone_constraint_panel_id(void *md_link, char *r_name)
static void bone_constraint_panel_id(void *md_link, char *r_idname)
{
bConstraint *con = (bConstraint *)md_link;
const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_from_type(con->type);
@@ -2431,9 +2430,7 @@ static void bone_constraint_panel_id(void *md_link, char *r_name)
if (cti == nullptr) {
return;
}
strcpy(r_name, CONSTRAINT_BONE_TYPE_PANEL_PREFIX);
strcat(r_name, cti->structName);
BLI_string_join(r_idname, BKE_ST_MAXNAME, CONSTRAINT_BONE_TYPE_PANEL_PREFIX, cti->structName);
}
void uiTemplateConstraints(uiLayout * /*layout*/, bContext *C, bool use_bone_constraints)