Geometry Nodes: Make simulation caching optional #107767

Merged
Hans Goudey merged 13 commits from HooglyBoogly/blender:simulation-use-cache-option into main 2023-05-10 16:01:44 +02:00
443 changed files with 2644 additions and 2342 deletions
Showing only changes of commit cced179060 - Show all commits

View File

@ -21,7 +21,7 @@
#define __WCWIDTH_H__
#ifndef __cplusplus
# if defined(__APPLE__) || defined(__NetBSD__)
# if defined(__APPLE__) || defined(__NetBSD__) || defined(__OpenBSD__)
/* The <uchar.h> standard header is missing on macOS. */
#include <stddef.h>
typedef unsigned int char32_t;

View File

@ -14,7 +14,6 @@ PassAccessorGPU::PassAccessorGPU(DeviceQueue *queue,
float exposure,
int num_samples)
: PassAccessor(pass_access_info, exposure, num_samples), queue_(queue)
{
}

View File

@ -118,7 +118,9 @@ ccl_device_inline int bsdf_sample(KernelGlobals kg,
{
/* For curves use the smooth normal, particularly for ribbons the geometric
* normal gives too much darkening otherwise. */
int label;
*eval = zero_spectrum();
*pdf = 0.f;
int label = LABEL_NONE;
const float3 Ng = (sd->type & PRIMITIVE_CURVE) ? sc->N : sd->Ng;
switch (sc->type) {
@ -536,6 +538,7 @@ ccl_device_inline
ccl_private float *pdf)
{
Spectrum eval = zero_spectrum();
*pdf = 0.f;
switch (sc->type) {
case CLOSURE_BSDF_DIFFUSE_ID:

View File

@ -8,7 +8,7 @@
/* Adopted from Libmv. */
#if !defined(__APPLE__) && !defined(__FreeBSD__) && !defined(__NetBSD__)
#if !defined(__APPLE__) && !defined(__FreeBSD__) && !defined(__NetBSD__) && !defined(__OpenBSD__)
/* Needed for memalign on Linux and _aligned_alloc on Windows. */
# ifdef FREE_WINDOWS
/* Make sure _aligned_malloc is included. */
@ -33,7 +33,7 @@ void *util_aligned_malloc(size_t size, int alignment)
return MEM_mallocN_aligned(size, alignment, "Cycles Aligned Alloc");
#elif defined(_WIN32)
return _aligned_malloc(size, alignment);
#elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__APPLE__)
#elif defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
void *result;
if (posix_memalign(&result, alignment, size)) {
/* Non-zero means allocation error

View File

@ -59,7 +59,7 @@ void *aligned_malloc(size_t size, size_t alignment)
#ifdef _WIN32
return _aligned_malloc(size, alignment);
#elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__APPLE__)
#elif defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
void *result;
if (posix_memalign(&result, alignment, size)) {

View File

@ -52,7 +52,7 @@ size_t malloc_usable_size(void *ptr);
# define UNLIKELY(x) (x)
#endif
#if !defined(__APPLE__) && !defined(__FreeBSD__) && !defined(__NetBSD__)
#if !defined(__APPLE__) && !defined(__FreeBSD__) && !defined(__NetBSD__) && !defined(__OpenBSD__)
// Needed for memalign on Linux and _aligned_alloc on Windows.
# include <malloc.h>

View File

@ -21,7 +21,8 @@
#include "libmv/base/aligned_malloc.h"
#include "libmv/logging/logging.h"
#if !defined(__APPLE__) && !defined(__FreeBSD__) && !defined(__NetBSD__)
#if !defined(__APPLE__) && !defined(__FreeBSD__) && !defined(__NetBSD__) && \
!defined(__OpenBSD__)
// Needed for memalign on Linux and _aligned_alloc on Windows.
# ifdef FREE_WINDOWS
/* make sure _aligned_malloc is included */
@ -44,7 +45,8 @@ namespace libmv {
void* aligned_malloc(int size, int alignment) {
#ifdef _WIN32
return _aligned_malloc(size, alignment);
#elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__APPLE__)
#elif defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) || \
defined(__OpenBSD__)
void* result;
if (posix_memalign(&result, alignment, size)) {

View File

@ -123,7 +123,7 @@ TEST_F(AssetLibraryServiceTest, library_from_reference)
Main dummy_main{};
std::string dummy_filepath = asset_library_root_ + SEP + "dummy.blend";
BLI_strncpy(dummy_main.filepath, dummy_filepath.c_str(), sizeof(dummy_main.filepath));
STRNCPY(dummy_main.filepath, dummy_filepath.c_str());
EXPECT_EQ(lib, service->get_asset_library(&dummy_main, ref))
<< "Getting the local (current file) reference with a main saved on disk should return "
"the an asset library for this directory";

View File

@ -252,25 +252,15 @@ void IDP_Reset(struct IDProperty *prop, const struct IDProperty *reference);
/* C11 const correctness for casts */
#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)
# define IDP_Float(prop) \
_Generic((prop), \
struct IDProperty *: (*(float *)&(prop)->data.val), \
const struct IDProperty *: (*(const float *)&(prop)->data.val))
_Generic((prop), struct IDProperty * : (*(float *)&(prop)->data.val), const struct IDProperty * : (*(const float *)&(prop)->data.val))
# define IDP_Double(prop) \
_Generic((prop), \
struct IDProperty *: (*(double *)&(prop)->data.val), \
const struct IDProperty *: (*(const double *)&(prop)->data.val))
_Generic((prop), struct IDProperty * : (*(double *)&(prop)->data.val), const struct IDProperty * : (*(const double *)&(prop)->data.val))
# define IDP_String(prop) \
_Generic((prop), \
struct IDProperty *: ((char *) (prop)->data.pointer), \
const struct IDProperty *: ((const char *) (prop)->data.pointer))
_Generic((prop), struct IDProperty * : ((char *)(prop)->data.pointer), const struct IDProperty * : ((const char *)(prop)->data.pointer))
# define IDP_IDPArray(prop) \
_Generic((prop), \
struct IDProperty *: ((struct IDProperty *) (prop)->data.pointer), \
const struct IDProperty *: ((const struct IDProperty *) (prop)->data.pointer))
_Generic((prop), struct IDProperty * : ((struct IDProperty *)(prop)->data.pointer), const struct IDProperty * : ((const struct IDProperty *)(prop)->data.pointer))
# define IDP_Id(prop) \
_Generic((prop), \
struct IDProperty *: ((ID *) (prop)->data.pointer), \
const struct IDProperty *: ((const ID *) (prop)->data.pointer))
_Generic((prop), struct IDProperty * : ((ID *)(prop)->data.pointer), const struct IDProperty * : ((const ID *)(prop)->data.pointer))
#else
# define IDP_Float(prop) (*(float *)&(prop)->data.val)
# define IDP_Double(prop) (*(double *)&(prop)->data.val)

View File

@ -776,11 +776,11 @@ struct MovieTrackingObject *BKE_tracking_find_object_for_plane_track(
void BKE_tracking_get_rna_path_for_track(const struct MovieTracking *tracking,
const struct MovieTrackingTrack *track,
char *rna_path,
size_t rna_path_len);
size_t rna_path_maxncpy);
void BKE_tracking_get_rna_path_prefix_for_track(const struct MovieTracking *tracking,
const struct MovieTrackingTrack *track,
char *rna_path,
size_t rna_path_len);
size_t rna_path_maxncpy);
void BKE_tracking_get_rna_path_for_plane_track(const struct MovieTracking *tracking,
const struct MovieTrackingPlaneTrack *plane_track,
char *rna_path,
@ -789,7 +789,7 @@ void BKE_tracking_get_rna_path_prefix_for_plane_track(
const struct MovieTracking *tracking,
const struct MovieTrackingPlaneTrack *plane_track,
char *rna_path,
size_t rna_path_len);
size_t rna_path_maxncpy);
/* --------------------------------------------------------------------
* Utility macros.

View File

@ -500,7 +500,7 @@ static void mesh_calc_finalize(const Mesh *mesh_input, Mesh *mesh_eval)
{
/* Make sure the name is the same. This is because mesh allocation from template does not
* take care of naming. */
BLI_strncpy(mesh_eval->id.name, mesh_input->id.name, sizeof(mesh_eval->id.name));
STRNCPY(mesh_eval->id.name, mesh_input->id.name);
/* Make evaluated mesh to share same edit mesh pointer as original and copied meshes. */
mesh_eval->edit_mesh = mesh_input->edit_mesh;
}

View File

@ -422,7 +422,7 @@ bActionGroup *action_groups_add_new(bAction *act, const char name[])
/* make it selected, with default name */
agrp->flag = AGRP_SELECTED;
BLI_strncpy(agrp->name, name[0] ? name : DATA_("Group"), sizeof(agrp->name));
STRNCPY(agrp->name, name[0] ? name : DATA_("Group"));
/* add to action, and validate */
BLI_addtail(&act->groups, agrp);
@ -645,7 +645,7 @@ bPoseChannel *BKE_pose_channel_ensure(bPose *pose, const char *name)
BKE_pose_channel_session_uuid_generate(chan);
BLI_strncpy(chan->name, name, sizeof(chan->name));
STRNCPY(chan->name, name);
copy_v3_fl(chan->custom_scale_xyz, 1.0f);
zero_v3(chan->custom_translation);
@ -1273,7 +1273,7 @@ bActionGroup *BKE_pose_add_group(bPose *pose, const char *name)
}
grp = MEM_callocN(sizeof(bActionGroup), "PoseGroup");
BLI_strncpy(grp->name, name, sizeof(grp->name));
STRNCPY(grp->name, name);
BLI_addtail(&pose->agroups, grp);
BLI_uniquename(&pose->agroups, grp, name, '.', offsetof(bActionGroup, name), sizeof(grp->name));
@ -1772,10 +1772,10 @@ void what_does_obaction(Object *ob,
}
}
BLI_strncpy(workob->parsubstr, ob->parsubstr, sizeof(workob->parsubstr));
STRNCPY(workob->parsubstr, ob->parsubstr);
/* we don't use real object name, otherwise RNA screws with the real thing */
BLI_strncpy(workob->id.name, "OB<ConstrWorkOb>", sizeof(workob->id.name));
STRNCPY(workob->id.name, "OB<ConstrWorkOb>");
/* If we're given a group to use, it's likely to be more efficient
* (though a bit more dangerous). */

View File

@ -46,7 +46,7 @@ bAddon *BKE_addon_ensure(ListBase *addon_list, const char *module)
bAddon *addon = BKE_addon_find(addon_list, module);
if (addon == NULL) {
addon = BKE_addon_new();
BLI_strncpy(addon->module, module, sizeof(addon->module));
STRNCPY(addon->module, module);
BLI_addtail(addon_list, addon);
}
return addon;

View File

@ -767,7 +767,7 @@ static bool fcurves_path_rename_fix(ID *owner_id,
bActionGroup *agrp = fcu->grp;
is_changed = true;
if (oldName != NULL && (agrp != NULL) && STREQ(oldName, agrp->name)) {
BLI_strncpy(agrp->name, newName, sizeof(agrp->name));
STRNCPY(agrp->name, newName);
}
}
}
@ -819,7 +819,7 @@ static bool drivers_path_rename_fix(ID *owner_id,
(dtar->pchan_name[0]) && STREQ(oldName, dtar->pchan_name))
{
is_changed = true;
BLI_strncpy(dtar->pchan_name, newName, sizeof(dtar->pchan_name));
STRNCPY(dtar->pchan_name, newName);
}
}
}

View File

@ -131,12 +131,8 @@ KeyingSet *BKE_keyingset_add(
/* allocate new KeyingSet */
ks = MEM_callocN(sizeof(KeyingSet), "KeyingSet");
BLI_strncpy(ks->idname,
(idname) ? idname :
(name) ? name :
DATA_("KeyingSet"),
sizeof(ks->idname));
BLI_strncpy(ks->name, (name) ? name : (idname) ? idname : DATA_("Keying Set"), sizeof(ks->name));
STRNCPY(ks->idname, (idname) ? idname : (name) ? name : DATA_("KeyingSet"));
STRNCPY(ks->name, (name) ? name : (idname) ? idname : DATA_("Keying Set"));
ks->flag = flag;
ks->keyingflag = keyingflag;
@ -193,7 +189,7 @@ KS_Path *BKE_keyingset_add_path(KeyingSet *ks,
/* just store absolute info */
ksp->id = id;
if (group_name) {
BLI_strncpy(ksp->group, group_name, sizeof(ksp->group));
STRNCPY(ksp->group, group_name);
}
else {
ksp->group[0] = '\0';
@ -608,13 +604,18 @@ static void animsys_evaluate_fcurves(PointerRNA *ptr,
}
}
/* This function assumes that the quaternion is keyed in array index order.
* If the quaternion is only partially keyed, the result is normalized.
* If it is fully keyed, the result is returned as-is. */
static void animsys_quaternion_evaluate_fcurves(PathResolvedRNA quat_rna,
FCurve *first_fcurve,
const AnimationEvalContext *anim_eval_context,
float r_quaternion[4])
/**
* This function assumes that the quaternion keys are sequential. They do not
* have to be in array_index order. If the quaternion is only partially keyed,
* the result is normalized. If it is fully keyed, the result is returned as-is.
*
* \return the number of FCurves used to construct this quaternion. This is so
* that the caller knows how many FCurves can be skipped while iterating over
* them. */
static int animsys_quaternion_evaluate_fcurves(PathResolvedRNA quat_rna,
FCurve *first_fcurve,
const AnimationEvalContext *anim_eval_context,
float r_quaternion[4])
{
FCurve *quat_curve_fcu = first_fcurve;
@ -625,46 +626,54 @@ static void animsys_quaternion_evaluate_fcurves(PathResolvedRNA quat_rna,
r_quaternion[2] = 0.0f;
r_quaternion[3] = 0.0f;
/* This should start at 0, but in the case of semi-keyed quaternions, the first FCurve may
* actually have a different array index. */
const int start_index = first_fcurve->array_index;
int prop_index = start_index;
for (; prop_index < 4 && quat_curve_fcu; ++prop_index, quat_curve_fcu = quat_curve_fcu->next) {
if (quat_curve_fcu->array_index != prop_index ||
!STREQ(quat_curve_fcu->rna_path, first_fcurve->rna_path))
{
/* This should never happen when the quaternion is fully keyed and stored in order. People
* do use half-keyed quaternions, though, so better to check anyway. */
int fcurve_offset = 0;
for (; fcurve_offset < 4 && quat_curve_fcu;
++fcurve_offset, quat_curve_fcu = quat_curve_fcu->next) {
if (!STREQ(quat_curve_fcu->rna_path, first_fcurve->rna_path)) {
/* This should never happen when the quaternion is fully keyed. Some
* people do use half-keyed quaternions, though, so better to check. */
break;
}
quat_rna.prop_index = prop_index;
r_quaternion[prop_index] = calculate_fcurve(&quat_rna, quat_curve_fcu, anim_eval_context);
const int array_index = quat_curve_fcu->array_index;
quat_rna.prop_index = array_index;
r_quaternion[array_index] = calculate_fcurve(&quat_rna, quat_curve_fcu, anim_eval_context);
}
if (start_index != 0 || prop_index < 4) {
if (fcurve_offset < 4) {
/* This quaternion was incompletely keyed, so the result is a mixture of the unit quaterion and
* values from FCurves. This means that it's almost certainly no longer of unit length. */
normalize_qt(r_quaternion);
}
return fcurve_offset;
}
/* This function assumes that the quaternion is fully keyed, and is stored in array index order. */
static void animsys_blend_fcurves_quaternion(PathResolvedRNA *anim_rna,
FCurve *first_fcurve,
const AnimationEvalContext *anim_eval_context,
const float blend_factor)
/**
* This function assumes that the quaternion keys are sequential. They do not
* have to be in array_index order.
*
* \return the number of FCurves used to construct the quaternion, counting from
* `first_fcurve`. This is so that the caller knows how many FCurves can be
* skipped while iterating over them. */
static int animsys_blend_fcurves_quaternion(PathResolvedRNA *anim_rna,
FCurve *first_fcurve,
const AnimationEvalContext *anim_eval_context,
const float blend_factor)
{
float current_quat[4];
RNA_property_float_get_array(&anim_rna->ptr, anim_rna->prop, current_quat);
float target_quat[4];
animsys_quaternion_evaluate_fcurves(*anim_rna, first_fcurve, anim_eval_context, target_quat);
const int num_fcurves_read = animsys_quaternion_evaluate_fcurves(
*anim_rna, first_fcurve, anim_eval_context, target_quat);
float blended_quat[4];
interp_qt_qtqt(blended_quat, current_quat, target_quat, blend_factor);
RNA_property_float_set_array(&anim_rna->ptr, anim_rna->prop, blended_quat);
return num_fcurves_read;
}
/* LERP between current value (blend_factor=0.0) and the value from the FCurve (blend_factor=1.0)
@ -699,12 +708,13 @@ static void animsys_blend_in_fcurves(PointerRNA *ptr,
}
if (STREQ(RNA_property_identifier(anim_rna.prop), "rotation_quaternion")) {
animsys_blend_fcurves_quaternion(&anim_rna, fcu, anim_eval_context, blend_factor);
const int num_fcurves_read = animsys_blend_fcurves_quaternion(
&anim_rna, fcu, anim_eval_context, blend_factor);
/* Skip the next three channels, because those have already been handled here. */
MEM_SAFE_FREE(channel_to_skip);
channel_to_skip = BLI_strdup(fcu->rna_path);
num_channels_to_skip = 3;
num_channels_to_skip = num_fcurves_read - 1;
continue;
}
/* TODO(Sybren): do something similar as above for Euler and Axis/Angle representations. */

View File

@ -115,7 +115,7 @@ static char *blender_version_decimal(const int version)
{
static char version_str[5];
BLI_assert(version < 1000);
BLI_snprintf(version_str, sizeof(version_str), "%d.%d", version / 100, version % 100);
SNPRINTF(version_str, "%d.%d", version / 100, version % 100);
return version_str;
}
@ -480,7 +480,7 @@ static bool get_path_user_ex(char *targetpath,
const char *user_base_path = GHOST_getUserDir(version, blender_version_decimal(version));
if (user_base_path) {
BLI_strncpy(user_path, user_base_path, FILE_MAX);
STRNCPY(user_path, user_base_path);
}
}
@ -546,7 +546,7 @@ static bool get_path_system_ex(char *targetpath,
system_path[0] = '\0';
const char *system_base_path = GHOST_getSystemDir(version, blender_version_decimal(version));
if (system_base_path) {
BLI_strncpy(system_path, system_base_path, FILE_MAX);
STRNCPY(system_path, system_base_path);
}
}

View File

@ -708,7 +708,7 @@ bool bone_autoside_name(
if (len == 0) {
return false;
}
BLI_strncpy(basename, name, sizeof(basename));
STRNCPY(basename, name);
/* Figure out extension to append:
* - The extension to append is based upon the axis that we are working on.

View File

@ -52,7 +52,7 @@ AssetMetaData::~AssetMetaData()
static AssetTag *asset_metadata_tag_add(AssetMetaData *asset_data, const char *const name)
{
AssetTag *tag = (AssetTag *)MEM_callocN(sizeof(*tag), __func__);
BLI_strncpy(tag->name, name, sizeof(tag->name));
STRNCPY(tag->name, name);
BLI_addtail(&asset_data->tags, tag);
asset_data->tot_tags++;

View File

@ -217,7 +217,7 @@ bool BKE_id_attribute_rename(ID *id,
BKE_id_attributes_default_color_set(id, result_name);
}
BLI_strncpy_utf8(layer->name, result_name, sizeof(layer->name));
STRNCPY_UTF8(layer->name, result_name);
return true;
}

View File

@ -111,13 +111,12 @@ static void blender_version_init(void)
BLI_assert_msg(0, "Invalid Blender version cycle");
}
BLI_snprintf(blender_version_string,
ARRAY_SIZE(blender_version_string),
"%d.%01d.%d%s",
BLENDER_VERSION / 100,
BLENDER_VERSION % 100,
BLENDER_VERSION_PATCH,
version_cycle);
SNPRINTF(blender_version_string,
"%d.%01d.%d%s",
BLENDER_VERSION / 100,
BLENDER_VERSION % 100,
BLENDER_VERSION_PATCH,
version_cycle);
}
const char *BKE_blender_version_string(void)

View File

@ -57,7 +57,7 @@ bool BKE_memfile_undo_decode(MemFileUndoData *mfu,
char mainstr[sizeof(bmain->filepath)];
int success = 0, fileflags;
BLI_strncpy(mainstr, BKE_main_blendfile_path(bmain), sizeof(mainstr)); /* temporal store */
STRNCPY(mainstr, BKE_main_blendfile_path(bmain)); /* temporal store */
fileflags = G.fileflags;
G.fileflags |= G_FILE_NO_UI;
@ -116,14 +116,14 @@ MemFileUndoData *BKE_memfile_undo_encode(Main *bmain, MemFileUndoData *mfu_prev)
counter++;
counter = counter % U.undosteps;
BLI_snprintf(numstr, sizeof(numstr), "%d.blend", counter);
SNPRINTF(numstr, "%d.blend", counter);
BLI_path_join(filepath, sizeof(filepath), BKE_tempdir_session(), numstr);
const BlendFileWriteParams blend_file_write_params{};
/* success = */ /* UNUSED */ BLO_write_file(
bmain, filepath, fileflags, &blend_file_write_params, nullptr);
BLI_strncpy(mfu->filepath, filepath, sizeof(mfu->filepath));
STRNCPY(mfu->filepath, filepath);
}
else {
MemFile *prevfile = (mfu_prev) ? &(mfu_prev->memfile) : nullptr;

View File

@ -1116,9 +1116,9 @@ void BKE_blendfile_append(BlendfileLinkAppendContext *lapp_context, ReportList *
ID *local_appended_new_id = NULL;
char lib_filepath[FILE_MAX];
BLI_strncpy(lib_filepath, id->lib->filepath, sizeof(lib_filepath));
STRNCPY(lib_filepath, id->lib->filepath);
char lib_id_name[MAX_ID_NAME];
BLI_strncpy(lib_id_name, id->name, sizeof(lib_id_name));
STRNCPY(lib_id_name, id->name);
switch (item->action) {
case LINK_APPEND_ACT_COPY_LOCAL:

View File

@ -1617,7 +1617,7 @@ BoidRule *boid_new_rule(int type)
rule->type = type;
rule->flag |= BOIDRULE_IN_AIR | BOIDRULE_ON_LAND;
BLI_strncpy(rule->name, DATA_(rna_enum_boidrule_type_items[type - 1].name), sizeof(rule->name));
STRNCPY(rule->name, DATA_(rna_enum_boidrule_type_items[type - 1].name));
return rule;
}
@ -1653,7 +1653,7 @@ BoidState *boid_new_state(BoidSettings *boids)
state->id = boids->last_state_id++;
if (state->id) {
BLI_snprintf(state->name, sizeof(state->name), "State %i", state->id);
SNPRINTF(state->name, "State %i", state->id);
}
else {
strcpy(state->name, "State");

View File

@ -135,7 +135,7 @@ bool BKE_bpath_foreach_path_fixed_process(BPathForeachPathData *bpath_data, char
char path_dst[FILE_MAX];
if (absolute_base_path) {
BLI_strncpy(path_src_buf, path, sizeof(path_src_buf));
STRNCPY(path_src_buf, path);
BLI_path_abs(path_src_buf, absolute_base_path);
path_src = path_src_buf;
}
@ -144,7 +144,7 @@ bool BKE_bpath_foreach_path_fixed_process(BPathForeachPathData *bpath_data, char
}
/* so functions can check old value */
BLI_strncpy(path_dst, path, FILE_MAX);
STRNCPY(path_dst, path);
if (bpath_data->callback_function(bpath_data, path_dst, path_src)) {
BLI_strncpy(path, path_dst, FILE_MAX);
@ -167,7 +167,7 @@ bool BKE_bpath_foreach_path_dirfile_fixed_process(BPathForeachPathData *bpath_da
BLI_path_join(path_src, sizeof(path_src), path_dir, path_file);
/* So that functions can access the old value. */
BLI_strncpy(path_dst, path_src, FILE_MAX);
STRNCPY(path_dst, path_src);
if (absolute_base_path) {
BLI_path_abs(path_src, absolute_base_path);
@ -191,7 +191,7 @@ bool BKE_bpath_foreach_path_allocated_process(BPathForeachPathData *bpath_data,
char path_dst[FILE_MAX];
if (absolute_base_path) {
BLI_strncpy(path_src_buf, *path, sizeof(path_src_buf));
STRNCPY(path_src_buf, *path);
BLI_path_abs(path_src_buf, absolute_base_path);
path_src = path_src_buf;
}

View File

@ -82,7 +82,7 @@ TEST_F(BPathTest, rebase_on_relative)
text->filepath = BLI_strdup(TEXT_PATH_RELATIVE);
MovieClip *movie_clip = reinterpret_cast<MovieClip *>(bmain->movieclips.first);
BLI_strncpy(movie_clip->filepath, MOVIECLIP_PATH_RELATIVE, sizeof(movie_clip->filepath));
STRNCPY(movie_clip->filepath, MOVIECLIP_PATH_RELATIVE);
BKE_bpath_relative_rebase(bmain, BASE_DIR, REBASE_DIR, nullptr);
@ -97,7 +97,7 @@ TEST_F(BPathTest, rebase_on_absolute)
text->filepath = BLI_strdup(TEXT_PATH_ABSOLUTE);
MovieClip *movie_clip = reinterpret_cast<MovieClip *>(bmain->movieclips.first);
BLI_strncpy(movie_clip->filepath, MOVIECLIP_PATH_ABSOLUTE, sizeof(movie_clip->filepath));
STRNCPY(movie_clip->filepath, MOVIECLIP_PATH_ABSOLUTE);
BKE_bpath_relative_rebase(bmain, BASE_DIR, REBASE_DIR, nullptr);
@ -111,7 +111,7 @@ TEST_F(BPathTest, convert_to_relative)
text->filepath = BLI_strdup(TEXT_PATH_RELATIVE);
MovieClip *movie_clip = reinterpret_cast<MovieClip *>(bmain->movieclips.first);
BLI_strncpy(movie_clip->filepath, MOVIECLIP_PATH_ABSOLUTE, sizeof(movie_clip->filepath));
STRNCPY(movie_clip->filepath, MOVIECLIP_PATH_ABSOLUTE);
BKE_bpath_relative_convert(bmain, BASE_DIR, nullptr);
@ -127,7 +127,7 @@ TEST_F(BPathTest, convert_to_absolute)
text->filepath = BLI_strdup(TEXT_PATH_RELATIVE);
MovieClip *movie_clip = reinterpret_cast<MovieClip *>(bmain->movieclips.first);
BLI_strncpy(movie_clip->filepath, MOVIECLIP_PATH_ABSOLUTE, sizeof(movie_clip->filepath));
STRNCPY(movie_clip->filepath, MOVIECLIP_PATH_ABSOLUTE);
BKE_bpath_absolute_convert(bmain, BASE_DIR, nullptr);
@ -143,7 +143,7 @@ TEST_F(BPathTest, list_backup_restore)
text->filepath = BLI_strdup(TEXT_PATH_RELATIVE);
MovieClip *movie_clip = reinterpret_cast<MovieClip *>(bmain->movieclips.first);
BLI_strncpy(movie_clip->filepath, MOVIECLIP_PATH_ABSOLUTE, sizeof(movie_clip->filepath));
STRNCPY(movie_clip->filepath, MOVIECLIP_PATH_ABSOLUTE);
void *path_list_handle = BKE_bpath_list_backup(bmain, static_cast<eBPathForeachFlag>(0));
@ -152,7 +152,7 @@ TEST_F(BPathTest, list_backup_restore)
MEM_freeN(text->filepath);
text->filepath = BLI_strdup(TEXT_PATH_ABSOLUTE);
BLI_strncpy(movie_clip->filepath, MOVIECLIP_PATH_RELATIVE, sizeof(movie_clip->filepath));
STRNCPY(movie_clip->filepath, MOVIECLIP_PATH_RELATIVE);
BKE_bpath_list_restore(bmain, static_cast<eBPathForeachFlag>(0), path_list_handle);

View File

@ -58,7 +58,7 @@ static void cache_file_init_data(ID *id)
cache_file->scale = 1.0f;
cache_file->velocity_unit = CACHEFILE_VELOCITY_UNIT_SECOND;
BLI_strncpy(cache_file->velocity_name, ".velocities", sizeof(cache_file->velocity_name));
STRNCPY(cache_file->velocity_name, ".velocities");
}
static void cache_file_copy_data(Main *UNUSED(bmain),
@ -362,7 +362,7 @@ void BKE_cachefile_eval(Main *bmain, Depsgraph *depsgraph, CacheFile *cache_file
cache_file->type = CACHEFILE_TYPE_ALEMBIC;
cache_file->handle = ABC_create_handle(
bmain, filepath, cache_file->layers.first, &cache_file->object_paths);
BLI_strncpy(cache_file->handle_filepath, filepath, FILE_MAX);
STRNCPY(cache_file->handle_filepath, filepath);
}
#endif
#ifdef WITH_USD
@ -441,7 +441,7 @@ CacheFileLayer *BKE_cachefile_add_layer(CacheFile *cache_file, const char filepa
const int num_layers = BLI_listbase_count(&cache_file->layers);
CacheFileLayer *layer = MEM_callocN(sizeof(CacheFileLayer), "CacheFileLayer");
BLI_strncpy(layer->filepath, filepath, sizeof(layer->filepath));
STRNCPY(layer->filepath, filepath);
BLI_addtail(&cache_file->layers, layer);

View File

@ -1034,7 +1034,7 @@ static Object *camera_multiview_advanced(const Scene *scene, Object *camera, con
}
if (STREQ(camera_name + (len_name - len_suffix), srv->suffix)) {
BLI_snprintf(name, sizeof(name), "%.*s%s", (len_name - len_suffix), camera_name, suffix);
SNPRINTF(name, "%.*s%s", (len_name - len_suffix), camera_name, suffix);
len_suffix_max = len_suffix;
}
}

View File

@ -1790,15 +1790,13 @@ void BKE_color_managed_display_settings_init(ColorManagedDisplaySettings *settin
{
const char *display_name = IMB_colormanagement_display_get_default_name();
BLI_strncpy(settings->display_device, display_name, sizeof(settings->display_device));
STRNCPY(settings->display_device, display_name);
}
void BKE_color_managed_display_settings_copy(ColorManagedDisplaySettings *new_settings,
const ColorManagedDisplaySettings *settings)
{
BLI_strncpy(new_settings->display_device,
settings->display_device,
sizeof(new_settings->display_device));
STRNCPY(new_settings->display_device, settings->display_device);
}
void BKE_color_managed_view_settings_init_render(
@ -1836,10 +1834,8 @@ void BKE_color_managed_view_settings_init_default(
void BKE_color_managed_view_settings_copy(ColorManagedViewSettings *new_settings,
const ColorManagedViewSettings *settings)
{
BLI_strncpy(new_settings->look, settings->look, sizeof(new_settings->look));
BLI_strncpy(new_settings->view_transform,
settings->view_transform,
sizeof(new_settings->view_transform));
STRNCPY(new_settings->look, settings->look);
STRNCPY(new_settings->view_transform, settings->view_transform);
new_settings->flag = settings->flag;
new_settings->exposure = settings->exposure;
@ -1882,14 +1878,14 @@ void BKE_color_managed_view_settings_blend_read_data(BlendDataReader *reader,
void BKE_color_managed_colorspace_settings_init(
ColorManagedColorspaceSettings *colorspace_settings)
{
BLI_strncpy(colorspace_settings->name, "", sizeof(colorspace_settings->name));
STRNCPY(colorspace_settings->name, "");
}
void BKE_color_managed_colorspace_settings_copy(
ColorManagedColorspaceSettings *colorspace_settings,
const ColorManagedColorspaceSettings *settings)
{
BLI_strncpy(colorspace_settings->name, settings->name, sizeof(colorspace_settings->name));
STRNCPY(colorspace_settings->name, settings->name);
}
bool BKE_color_managed_colorspace_settings_equals(const ColorManagedColorspaceSettings *settings1,

View File

@ -859,7 +859,7 @@ static void default_get_tarmat_full_bbone(struct Depsgraph *UNUSED(depsgraph),
ct = MEM_callocN(sizeof(bConstraintTarget), "tempConstraintTarget"); \
\
ct->tar = datatar; \
BLI_strncpy(ct->subtarget, datasubtarget, sizeof(ct->subtarget)); \
STRNCPY(ct->subtarget, datasubtarget); \
ct->space = con->tarspace; \
ct->flag = CONSTRAINT_TAR_TEMP; \
\
@ -916,7 +916,7 @@ static void default_get_tarmat_full_bbone(struct Depsgraph *UNUSED(depsgraph),
bConstraintTarget *ctn = ct->next; \
if (no_copy == 0) { \
datatar = ct->tar; \
BLI_strncpy(datasubtarget, ct->subtarget, sizeof(datasubtarget)); \
STRNCPY(datasubtarget, ct->subtarget); \
con->tarspace = (char)ct->space; \
} \
\
@ -5403,7 +5403,7 @@ static void transformcache_copy(bConstraint *con, bConstraint *srccon)
bTransformCacheConstraint *src = srccon->data;
bTransformCacheConstraint *dst = con->data;
BLI_strncpy(dst->object_path, src->object_path, sizeof(dst->object_path));
STRNCPY(dst->object_path, src->object_path);
dst->cache_file = src->cache_file;
dst->reader = NULL;
dst->reader_object_path[0] = '\0';
@ -5779,7 +5779,7 @@ static bConstraint *add_new_constraint_internal(const char *name, short type)
}
/* copy the name */
BLI_strncpy(con->name, newName, sizeof(con->name));
STRNCPY(con->name, newName);
/* return the new constraint */
return con;
@ -6201,7 +6201,7 @@ void BKE_constraint_targets_flush(struct bConstraint *con, struct ListBase *targ
if (!no_copy) {
con->space_object = ct->tar;
BLI_strncpy(con->space_subtarget, ct->subtarget, sizeof(con->space_subtarget));
STRNCPY(con->space_subtarget, ct->subtarget);
}
BLI_freelinkN(targets, ct);

View File

@ -146,7 +146,7 @@ TEST(cryptomatte, session_from_stamp_data)
/* Create StampData from CryptomatteSession. */
ViewLayer view_layer;
BLI_strncpy(view_layer.name, "viewlayername", sizeof(view_layer.name));
STRNCPY(view_layer.name, "viewlayername");
RenderResult *render_result2 = static_cast<RenderResult *>(
MEM_callocN(sizeof(RenderResult), __func__));
BKE_cryptomatte_store_metadata(session.get(), render_result2, &view_layer);

View File

@ -2955,7 +2955,7 @@ static CustomDataLayer *customData_add_layer__internal(
}
if (name) {
BLI_strncpy(new_layer.name, name, sizeof(new_layer.name));
STRNCPY(new_layer.name, name);
CustomData_set_layer_unique_name(data, index);
}
else {
@ -3669,7 +3669,7 @@ bool CustomData_set_layer_name(CustomData *data,
return false;
}
BLI_strncpy(data->layers[layer_index].name, name, sizeof(data->layers[layer_index].name));
STRNCPY(data->layers[layer_index].name, name);
return true;
}
@ -4781,7 +4781,7 @@ void CustomData_external_add(CustomData *data,
external = MEM_cnew<CustomDataExternal>(__func__);
data->external = external;
}
BLI_strncpy(external->filepath, filepath, sizeof(external->filepath));
STRNCPY(external->filepath, filepath);
layer->flag |= CD_FLAG_EXTERNAL | CD_FLAG_IN_MEMORY;
}

View File

@ -444,7 +444,7 @@ CDataFileLayer *cdf_layer_add(CDataFile *cdf, int type, const char *name, size_t
layer->datatype = CDF_DATA_FLOAT;
layer->datasize = datasize;
layer->type = type;
BLI_strncpy(layer->name, name, CDF_LAYER_NAME_MAX);
STRNCPY(layer->name, name);
return layer;
}

View File

@ -48,7 +48,7 @@ bDeformGroup *BKE_object_defgroup_new(Object *ob, const char *name)
defgroup = MEM_cnew<bDeformGroup>(__func__);
BLI_strncpy(defgroup->name, name, sizeof(defgroup->name));
STRNCPY(defgroup->name, name);
ListBase *defbase = BKE_object_defgroup_list_mutable(ob);

View File

@ -761,7 +761,7 @@ static GeometrySet curve_calc_modifiers_post(Depsgraph *depsgraph,
BKE_mesh_ensure_normals_for_display(final_mesh);
BLI_strncpy(final_mesh->id.name, cu->id.name, sizeof(final_mesh->id.name));
STRNCPY(final_mesh->id.name, cu->id.name);
*((short *)final_mesh->id.name) = ID_ME;
}

View File

@ -295,7 +295,7 @@ static Mesh *dynamicPaint_brush_mesh_get(DynamicPaintBrushSettings *brush)
static bool setError(DynamicPaintCanvasSettings *canvas, const char *string)
{
/* Add error to canvas ui info label */
BLI_strncpy(canvas->error, string, sizeof(canvas->error));
STRNCPY(canvas->error, string);
CLOG_STR_ERROR(&LOG, string);
return false;
}
@ -369,7 +369,7 @@ static bool surface_duplicateOutputExists(void *arg, const char *name)
static void surface_setUniqueOutputName(DynamicPaintSurface *surface, char *basename, int output)
{
char name[64];
BLI_strncpy(name, basename, sizeof(name)); /* in case basename is surface->name use a copy */
STRNCPY(name, basename); /* in case basename is surface->name use a copy */
if (output == 0) {
BLI_uniquename_cb(surface_duplicateOutputExists,
surface,
@ -405,7 +405,7 @@ static bool surface_duplicateNameExists(void *arg, const char *name)
void dynamicPaintSurface_setUniqueName(DynamicPaintSurface *surface, const char *basename)
{
char name[64];
BLI_strncpy(name, basename, sizeof(name)); /* in case basename is surface->name use a copy */
STRNCPY(name, basename); /* in case basename is surface->name use a copy */
BLI_uniquename_cb(
surface_duplicateNameExists, surface, name, '.', surface->name, sizeof(surface->name));
}
@ -420,7 +420,7 @@ void dynamicPaintSurface_updateType(DynamicPaintSurface *surface)
}
else {
strcpy(surface->output_name, "dp_");
BLI_strncpy(surface->output_name2, surface->output_name, sizeof(surface->output_name2));
STRNCPY(surface->output_name2, surface->output_name);
surface->flags &= ~MOD_DPAINT_ANTIALIAS;
surface->depth_clamp = 0.0f;
}
@ -1233,7 +1233,7 @@ void dynamicPaint_Modifier_copy(const DynamicPaintModifierData *pmd,
t_surface->effector_weights = static_cast<EffectorWeights *>(
MEM_dupallocN(surface->effector_weights));
BLI_strncpy(t_surface->name, surface->name, sizeof(t_surface->name));
STRNCPY(t_surface->name, surface->name);
t_surface->format = surface->format;
t_surface->type = surface->type;
t_surface->disp_type = surface->disp_type;
@ -1250,8 +1250,7 @@ void dynamicPaint_Modifier_copy(const DynamicPaintModifierData *pmd,
copy_v4_v4(t_surface->init_color, surface->init_color);
t_surface->init_texture = surface->init_texture;
BLI_strncpy(
t_surface->init_layername, surface->init_layername, sizeof(t_surface->init_layername));
STRNCPY(t_surface->init_layername, surface->init_layername);
t_surface->dry_speed = surface->dry_speed;
t_surface->diss_speed = surface->diss_speed;
@ -1274,12 +1273,10 @@ void dynamicPaint_Modifier_copy(const DynamicPaintModifierData *pmd,
t_surface->wave_spring = surface->wave_spring;
t_surface->wave_smoothness = surface->wave_smoothness;
BLI_strncpy(t_surface->uvlayer_name, surface->uvlayer_name, sizeof(t_surface->uvlayer_name));
BLI_strncpy(t_surface->image_output_path,
surface->image_output_path,
sizeof(t_surface->image_output_path));
BLI_strncpy(t_surface->output_name, surface->output_name, sizeof(t_surface->output_name));
BLI_strncpy(t_surface->output_name2, surface->output_name2, sizeof(t_surface->output_name2));
STRNCPY(t_surface->uvlayer_name, surface->uvlayer_name);
STRNCPY(t_surface->image_output_path, surface->image_output_path);
STRNCPY(t_surface->output_name, surface->output_name);
STRNCPY(t_surface->output_name2, surface->output_name2);
}
}
if (tpmd->brush) {
@ -3314,7 +3311,7 @@ void dynamicPaint_outputSurfaceImage(DynamicPaintSurface *surface,
format = R_IMF_IMTYPE_PNG;
}
#endif
BLI_strncpy(output_file, filepath, sizeof(output_file));
STRNCPY(output_file, filepath);
BKE_image_path_ext_from_imtype_ensure(output_file, sizeof(output_file), format);
/* Validate output file path */

View File

@ -1351,7 +1351,7 @@ void BKE_sim_debug_data_add_element(int type,
zero_v3(elem->v2);
}
if (str) {
BLI_strncpy(elem->str, str, sizeof(elem->str));
STRNCPY(elem->str, str);
}
else {
elem->str[0] = '\0';

View File

@ -161,7 +161,7 @@ void BKE_fcurves_copy(ListBase *dst, ListBase *src)
void BKE_fmodifier_name_set(FModifier *fcm, const char *name)
{
/* Copy new Modifier name. */
BLI_strncpy(fcm->name, name, sizeof(fcm->name));
STRNCPY(fcm->name, name);
/* Set default modifier name when name parameter is an empty string.
* Ensure the name is unique. */
@ -1305,7 +1305,7 @@ void BKE_fcurve_handles_recalc_ex(FCurve *fcu, eBezTriple_Flag handle_sel_flag)
if (a == 1) {
next = cycle_offset_triple(cycle, &tmp, &fcu->bezt[1], first, last);
}
else {
else if (next != NULL) {
next++;
}

View File

@ -4455,12 +4455,12 @@ void BKE_fluid_particle_system_create(Main *bmain,
part->phystype = PART_PHYS_NO; /* No physics needed, part system only used to display data. */
psys->part = part;
psys->pointcache = BKE_ptcache_add(&psys->ptcaches);
BLI_strncpy(psys->name, parts_name, sizeof(psys->name));
STRNCPY(psys->name, parts_name);
BLI_addtail(&ob->particlesystem, psys);
/* add modifier */
pfmd = (ParticleSystemModifierData *)BKE_modifier_new(eModifierType_ParticleSystem);
BLI_strncpy(pfmd->modifier.name, psys_name, sizeof(pfmd->modifier.name));
STRNCPY(pfmd->modifier.name, psys_name);
pfmd->psys = psys;
BLI_addtail(&ob->modifiers, pfmd);
BKE_modifier_unique_name(&ob->modifiers, (ModifierData *)pfmd);
@ -4968,7 +4968,7 @@ void BKE_fluid_modifier_copy(const FluidModifierData *fmd, FluidModifierData *tf
tfds->cache_data_format = fds->cache_data_format;
tfds->cache_particle_format = fds->cache_particle_format;
tfds->cache_noise_format = fds->cache_noise_format;
BLI_strncpy(tfds->cache_directory, fds->cache_directory, sizeof(tfds->cache_directory));
STRNCPY(tfds->cache_directory, fds->cache_directory);
/* time options */
tfds->time_scale = fds->time_scale;
@ -5056,7 +5056,7 @@ void BKE_fluid_modifier_copy(const FluidModifierData *fmd, FluidModifierData *tf
/* texture control */
tffs->texture_size = ffs->texture_size;
tffs->texture_offset = ffs->texture_offset;
BLI_strncpy(tffs->uvlayer_name, ffs->uvlayer_name, sizeof(tffs->uvlayer_name));
STRNCPY(tffs->uvlayer_name, ffs->uvlayer_name);
tffs->vgroup_density = ffs->vgroup_density;
tffs->type = ffs->type;

View File

@ -180,10 +180,10 @@ FreestyleLineSet *BKE_freestyle_lineset_add(struct Main *bmain,
lineset->exclude_edge_types = 0;
lineset->group = NULL;
if (name) {
BLI_strncpy(lineset->name, name, sizeof(lineset->name));
STRNCPY(lineset->name, name);
}
else if (lineset_index > 0) {
BLI_snprintf(lineset->name, sizeof(lineset->name), "LineSet %i", lineset_index + 1);
SNPRINTF(lineset->name, "LineSet %i", lineset_index + 1);
}
else {
strcpy(lineset->name, "LineSet");

View File

@ -675,7 +675,7 @@ bGPDlayer *BKE_gpencil_layer_addnew(bGPdata *gpd,
}
/* auto-name */
BLI_strncpy(gpl->info, DATA_(name), sizeof(gpl->info));
STRNCPY(gpl->info, DATA_(name));
BLI_uniquename(&gpd->layers,
gpl,
(gpd->flag & GP_DATA_ANNOTATIONS) ? DATA_("Note") : DATA_("GP_Layer"),
@ -1018,9 +1018,9 @@ void BKE_gpencil_layer_copy_settings(const bGPDlayer *gpl_src, bGPDlayer *gpl_ds
gpl_dst->pass_index = gpl_src->pass_index;
gpl_dst->parent = gpl_src->parent;
copy_m4_m4(gpl_dst->inverse, gpl_src->inverse);
BLI_strncpy(gpl_dst->parsubstr, gpl_src->parsubstr, 64);
STRNCPY(gpl_dst->parsubstr, gpl_src->parsubstr);
gpl_dst->partype = gpl_src->partype;
BLI_strncpy(gpl_dst->viewlayername, gpl_src->viewlayername, 64);
STRNCPY(gpl_dst->viewlayername, gpl_src->viewlayername);
copy_v3_v3(gpl_dst->location, gpl_src->location);
copy_v3_v3(gpl_dst->rotation, gpl_src->rotation);
copy_v3_v3(gpl_dst->scale, gpl_src->scale);
@ -1436,7 +1436,7 @@ bGPDlayer_Mask *BKE_gpencil_layer_mask_add(bGPDlayer *gpl, const char *name)
bGPDlayer_Mask *mask = MEM_callocN(sizeof(bGPDlayer_Mask), "bGPDlayer_Mask");
BLI_addtail(&gpl->mask_layers, mask);
BLI_strncpy(mask->name, name, sizeof(mask->name));
STRNCPY(mask->name, name);
gpl->act_mask++;
return mask;

View File

@ -356,7 +356,7 @@ GpencilModifierData *BKE_gpencil_modifier_new(int type)
GpencilModifierData *md = MEM_callocN(mti->struct_size, mti->struct_name);
/* NOTE: this name must be made unique later. */
BLI_strncpy(md->name, DATA_(mti->name), sizeof(md->name));
STRNCPY(md->name, DATA_(mti->name));
md->type = type;
md->mode = eGpencilModifierMode_Realtime | eGpencilModifierMode_Render;

View File

@ -65,7 +65,7 @@ IDProperty *IDP_NewIDPArray(const char *name)
IDProperty *prop = MEM_callocN(sizeof(IDProperty), "IDProperty prop array");
prop->type = IDP_IDPARRAY;
prop->len = 0;
BLI_strncpy(prop->name, name, MAX_IDPROP_NAME);
STRNCPY(prop->name, name);
return prop;
}
@ -300,7 +300,7 @@ static IDProperty *idp_generic_copy(const IDProperty *prop, const int UNUSED(fla
{
IDProperty *newp = MEM_callocN(sizeof(IDProperty), __func__);
BLI_strncpy(newp->name, prop->name, MAX_IDPROP_NAME);
STRNCPY(newp->name, prop->name);
newp->type = prop->type;
newp->flag = prop->flag;
newp->data.val = prop->data.val;
@ -369,7 +369,7 @@ IDProperty *IDP_NewStringMaxSize(const char *st, const char *name, int maxncpy)
}
prop->type = IDP_STRING;
BLI_strncpy(prop->name, name, MAX_IDPROP_NAME);
STRNCPY(prop->name, name);
return prop;
}
@ -1005,7 +1005,7 @@ IDProperty *IDP_New(const char type, const IDPropertyTemplate *val, const char *
}
prop->type = type;
BLI_strncpy(prop->name, name, MAX_IDPROP_NAME);
STRNCPY(prop->name, name);
return prop;
}

View File

@ -67,7 +67,7 @@ static void idp_str_append_escape(struct ReprState *state,
state->str_append_fn(state->user_data, str + i_prev, i - i_prev);
}
char buf[5];
uint len = (uint)BLI_snprintf_rlen(buf, sizeof(buf), "\\x%02x", c);
uint len = (uint)SNPRINTF_RLEN(buf, "\\x%02x", c);
BLI_assert(len == 4);
state->str_append_fn(state->user_data, buf, len);
i_prev = i + 1;
@ -90,9 +90,7 @@ static void idp_repr_fn_recursive(struct ReprState *state, const IDProperty *pro
#define STR_APPEND_FMT(format, ...) \
state->str_append_fn( \
state->user_data, \
state->buf, \
(uint)BLI_snprintf_rlen(state->buf, sizeof(state->buf), format, __VA_ARGS__))
state->user_data, state->buf, (uint)SNPRINTF_RLEN(state->buf, format, __VA_ARGS__))
switch (prop->type) {
case IDP_STRING: {

View File

@ -290,7 +290,7 @@ static void image_foreach_path(ID *id, BPathForeachPathData *bpath_data)
bool result = false;
if (ima->source == IMA_SRC_TILED && (flag & BKE_BPATH_FOREACH_PATH_RESOLVE_TOKEN) != 0) {
char temp_path[FILE_MAX], orig_file[FILE_MAXFILE];
BLI_strncpy(temp_path, ima->filepath, sizeof(temp_path));
STRNCPY(temp_path, ima->filepath);
BLI_path_split_file_part(temp_path, orig_file, sizeof(orig_file));
eUDIM_TILE_FORMAT tile_format;
@ -3195,7 +3195,7 @@ void BKE_image_signal(Main *bmain, Image *ima, ImageUser *iuser, int signal)
int new_start, new_range;
char filepath[FILE_MAX];
BLI_strncpy(filepath, ima->filepath, sizeof(filepath));
STRNCPY(filepath, ima->filepath);
BLI_path_abs(filepath, ID_BLEND_PATH_FROM_GLOBAL(&ima->id));
bool result = BKE_image_get_tile_info(filepath, &new_tiles, &new_start, &new_range);
if (result) {
@ -3407,7 +3407,7 @@ ImageTile *BKE_image_add_tile(struct Image *ima, int tile_number, const char *la
}
if (label) {
BLI_strncpy(tile->label, label, sizeof(tile->label));
STRNCPY(tile->label, label);
}
for (int eye = 0; eye < 2; eye++) {
@ -5561,11 +5561,11 @@ RenderSlot *BKE_image_add_renderslot(Image *ima, const char *name)
{
RenderSlot *slot = MEM_cnew<RenderSlot>("Image new Render Slot");
if (name && name[0]) {
BLI_strncpy(slot->name, name, sizeof(slot->name));
STRNCPY(slot->name, name);
}
else {
int n = BLI_listbase_count(&ima->renderslots) + 1;
BLI_snprintf(slot->name, sizeof(slot->name), DATA_("Slot %d"), n);
SNPRINTF(slot->name, DATA_("Slot %d"), n);
}
BLI_addtail(&ima->renderslots, slot);
return slot;

View File

@ -167,7 +167,7 @@ bool BKE_image_save_options_init(ImageSaveOptions *opts,
const bool is_prev_save = !STREQ(G.ima, "//");
if (opts->save_as_render) {
if (is_prev_save) {
BLI_strncpy(opts->filepath, G.ima, sizeof(opts->filepath));
STRNCPY(opts->filepath, G.ima);
}
else {
BLI_path_join(opts->filepath, sizeof(opts->filepath), "//", DATA_("untitled"));
@ -252,7 +252,7 @@ static void image_save_update_filepath(Image *ima,
const ImageSaveOptions *opts)
{
if (opts->do_newpath) {
BLI_strncpy(ima->filepath, filepath, sizeof(ima->filepath));
STRNCPY(ima->filepath, filepath);
/* only image path, never ibuf */
if (opts->relative) {
@ -281,7 +281,7 @@ static void image_save_post(ReportList *reports,
}
if (opts->do_newpath) {
BLI_strncpy(ibuf->filepath, filepath, sizeof(ibuf->filepath));
STRNCPY(ibuf->filepath, filepath);
}
/* The tiled image code-path must call this on its own. */
@ -776,7 +776,7 @@ bool BKE_image_render_write_exr(ReportList *reports,
if (multi_layer) {
RE_render_result_full_channel_name(passname, nullptr, "Combined", nullptr, chan_id, a);
BLI_strncpy(layname, "Composite", sizeof(layname));
STRNCPY(layname, "Composite");
}
else {
passname[0] = chan_id[a];
@ -842,7 +842,7 @@ bool BKE_image_render_write_exr(ReportList *reports,
if (multi_layer) {
RE_render_result_full_channel_name(passname, nullptr, rp->name, nullptr, rp->chan_id, a);
BLI_strncpy(layname, rl->name, sizeof(layname));
STRNCPY(layname, rl->name);
}
else {
passname[0] = rp->chan_id[a];

View File

@ -17,7 +17,7 @@ TEST(udim, image_ensure_tile_token)
auto verify = [](const char *original, const char *expected) {
char result[FILE_MAX];
BLI_strncpy(result, original, sizeof(result));
STRNCPY(result, original);
BKE_image_ensure_tile_token_filename_only(result, sizeof(result));
EXPECT_STREQ(result, expected);
};
@ -172,7 +172,7 @@ TEST(udim, image_set_filepath_from_tile_number)
char filepath[FILE_MAX];
/* Parameter validation. */
BLI_strncpy(filepath, "xxxx", FILE_MAX);
STRNCPY(filepath, "xxxx");
BKE_image_set_filepath_from_tile_number(nullptr, udim_pattern, tile_format, 1028);
BKE_image_set_filepath_from_tile_number(filepath, nullptr, tile_format, 1028);

View File

@ -445,7 +445,7 @@ static char *shapekey_adrcodes_to_paths(ID *id, int adrcode, int *UNUSED(array_i
/* block will be attached to ID_KE block... */
if (adrcode == 0) {
/* adrcode=0 was the misnamed "speed" curve (now "evaluation time") */
BLI_strncpy(buf, "eval_time", sizeof(buf));
STRNCPY(buf, "eval_time");
}
else {
/* Find the name of the ShapeKey (i.e. KeyBlock) to look for */
@ -457,11 +457,11 @@ static char *shapekey_adrcodes_to_paths(ID *id, int adrcode, int *UNUSED(array_i
/* Use the keyblock name, escaped, so that path lookups for this will work */
char kb_name_esc[sizeof(kb->name) * 2];
BLI_str_escape(kb_name_esc, kb->name, sizeof(kb_name_esc));
BLI_snprintf(buf, sizeof(buf), "key_blocks[\"%s\"].value", kb_name_esc);
SNPRINTF(buf, "key_blocks[\"%s\"].value", kb_name_esc);
}
else {
/* Fallback - Use the adrcode as index directly, so that this can be manually fixed */
BLI_snprintf(buf, sizeof(buf), "key_blocks[%d].value", adrcode);
SNPRINTF(buf, "key_blocks[%d].value", adrcode);
}
}
return buf;
@ -580,7 +580,7 @@ static const char *mtex_adrcodes_to_paths(int adrcode, int *UNUSED(array_index))
/* only build and return path if there's a property */
if (prop) {
BLI_snprintf(buf, 128, "%s.%s", base, prop);
SNPRINTF(buf, "%s.%s", base, prop);
return buf;
}
@ -1154,8 +1154,7 @@ static char *get_rna_access(ID *id,
char constname_esc[sizeof(((bConstraint *)NULL)->name) * 2];
BLI_str_escape(actname_esc, actname, sizeof(actname_esc));
BLI_str_escape(constname_esc, constname, sizeof(constname_esc));
BLI_snprintf(
buf, sizeof(buf), "pose.bones[\"%s\"].constraints[\"%s\"]", actname_esc, constname_esc);
SNPRINTF(buf, "pose.bones[\"%s\"].constraints[\"%s\"]", actname_esc, constname_esc);
}
else if (actname && actname[0]) {
if ((blocktype == ID_OB) && STREQ(actname, "Object")) {
@ -1171,20 +1170,20 @@ static char *get_rna_access(ID *id,
/* Pose-Channel */
char actname_esc[sizeof(((bActionChannel *)NULL)->name) * 2];
BLI_str_escape(actname_esc, actname, sizeof(actname_esc));
BLI_snprintf(buf, sizeof(buf), "pose.bones[\"%s\"]", actname_esc);
SNPRINTF(buf, "pose.bones[\"%s\"]", actname_esc);
}
}
else if (constname && constname[0]) {
/* Constraint in Object */
char constname_esc[sizeof(((bConstraint *)NULL)->name) * 2];
BLI_str_escape(constname_esc, constname, sizeof(constname_esc));
BLI_snprintf(buf, sizeof(buf), "constraints[\"%s\"]", constname_esc);
SNPRINTF(buf, "constraints[\"%s\"]", constname_esc);
}
else if (seq) {
/* Sequence names in Scene */
char seq_name_esc[(sizeof(seq->name) - 2) * 2];
BLI_str_escape(seq_name_esc, seq->name + 2, sizeof(seq_name_esc));
BLI_snprintf(buf, sizeof(buf), "sequence_editor.sequences_all[\"%s\"]", seq_name_esc);
SNPRINTF(buf, "sequence_editor.sequences_all[\"%s\"]", seq_name_esc);
}
else {
buf[0] = '\0'; /* empty string */
@ -1202,7 +1201,7 @@ static char *get_rna_access(ID *id,
/* if there was no array index pointer provided, add it to the path */
if (array_index == NULL) {
BLI_snprintf(buf, sizeof(buf), "[\"%d\"]", dummy_index);
SNPRINTF(buf, "[\"%d\"]", dummy_index);
BLI_dynstr_append(path, buf);
}
@ -1261,7 +1260,7 @@ static ChannelDriver *idriver_to_cdriver(IpoDriver *idriver)
/* FIXME: expression will be useless due to API changes, but at least not totally lost */
cdriver->type = DRIVER_TYPE_PYTHON;
if (idriver->name[0]) {
BLI_strncpy(cdriver->expression, idriver->name, sizeof(cdriver->expression));
STRNCPY(cdriver->expression, idriver->name);
}
}
else {
@ -1283,7 +1282,7 @@ static ChannelDriver *idriver_to_cdriver(IpoDriver *idriver)
dtar->id = (ID *)idriver->ob;
dtar->idtype = ID_OB;
if (idriver->name[0]) {
BLI_strncpy(dtar->pchan_name, idriver->name, sizeof(dtar->pchan_name));
STRNCPY(dtar->pchan_name, idriver->name);
}
/* second bone target (name was stored in same var as the first one) */
@ -1291,8 +1290,7 @@ static ChannelDriver *idriver_to_cdriver(IpoDriver *idriver)
dtar->id = (ID *)idriver->ob;
dtar->idtype = ID_OB;
if (idriver->name[0]) { /* XXX: for safety. */
BLI_strncpy(
dtar->pchan_name, idriver->name + DRIVER_NAME_OFFS, sizeof(dtar->pchan_name));
STRNCPY(dtar->pchan_name, idriver->name + DRIVER_NAME_OFFS);
}
}
else {
@ -1305,7 +1303,7 @@ static ChannelDriver *idriver_to_cdriver(IpoDriver *idriver)
dtar->id = (ID *)idriver->ob;
dtar->idtype = ID_OB;
if (idriver->name[0]) {
BLI_strncpy(dtar->pchan_name, idriver->name, sizeof(dtar->pchan_name));
STRNCPY(dtar->pchan_name, idriver->name);
}
dtar->transChan = adrcode_to_dtar_transchan(idriver->adrcode);
dtar->flag |= DTAR_FLAG_LOCALSPACE; /* old drivers took local space */
@ -1362,7 +1360,7 @@ static void fcurve_add_to_list(
agrp->flag |= AGRP_MUTED;
}
BLI_strncpy(agrp->name, grpname, sizeof(agrp->name));
STRNCPY(agrp->name, grpname);
BLI_addtail(&tmp_act.groups, agrp);
BLI_uniquename(&tmp_act.groups,
@ -1876,7 +1874,7 @@ static void ipo_to_animdata(
if (adt->action == NULL) {
char nameBuf[MAX_ID_NAME];
BLI_snprintf(nameBuf, sizeof(nameBuf), "CDA:%s", ipo->id.name + 2);
SNPRINTF(nameBuf, "CDA:%s", ipo->id.name + 2);
adt->action = BKE_action_add(bmain, nameBuf);
if (G.debug & G_DEBUG) {

View File

@ -1841,14 +1841,14 @@ KeyBlock *BKE_keyblock_add(Key *key, const char *name)
tot = BLI_listbase_count(&key->block);
if (name) {
BLI_strncpy(kb->name, name, sizeof(kb->name));
STRNCPY(kb->name, name);
}
else {
if (tot == 1) {
BLI_strncpy(kb->name, DATA_("Basis"), sizeof(kb->name));
STRNCPY(kb->name, DATA_("Basis"));
}
else {
BLI_snprintf(kb->name, sizeof(kb->name), DATA_("Key %d"), tot - 1);
SNPRINTF(kb->name, DATA_("Key %d"), tot - 1);
}
}
@ -1961,7 +1961,7 @@ void BKE_keyblock_copy_settings(KeyBlock *kb_dst, const KeyBlock *kb_src)
kb_dst->curval = kb_src->curval;
kb_dst->type = kb_src->type;
kb_dst->relative = kb_src->relative;
BLI_strncpy(kb_dst->vgroup, kb_src->vgroup, sizeof(kb_dst->vgroup));
STRNCPY(kb_dst->vgroup, kb_src->vgroup);
kb_dst->slidermin = kb_src->slidermin;
kb_dst->slidermax = kb_src->slidermax;
}

View File

@ -161,7 +161,7 @@ static ViewLayer *view_layer_add(const char *name)
ViewLayer *view_layer = MEM_cnew<ViewLayer>("View Layer");
view_layer->flag = VIEW_LAYER_RENDER | VIEW_LAYER_FREESTYLE;
BLI_strncpy_utf8(view_layer->name, name, sizeof(view_layer->name));
STRNCPY_UTF8(view_layer->name, name);
/* Pure rendering pipeline settings. */
view_layer->layflag = SCE_LAY_FLAG_DEFAULT;
@ -210,7 +210,7 @@ ViewLayer *BKE_view_layer_add(Scene *scene,
BKE_view_layer_copy_data(scene, scene, view_layer_new, view_layer_source, 0);
BLI_addtail(&scene->view_layers, view_layer_new);
BLI_strncpy_utf8(view_layer_new->name, name, sizeof(view_layer_new->name));
STRNCPY_UTF8(view_layer_new->name, name);
break;
}
case VIEWLAYER_ADD_EMPTY: {
@ -553,9 +553,9 @@ void BKE_view_layer_rename(Main *bmain, Scene *scene, ViewLayer *view_layer, con
{
char oldname[sizeof(view_layer->name)];
BLI_strncpy(oldname, view_layer->name, sizeof(view_layer->name));
STRNCPY(oldname, view_layer->name);
BLI_strncpy_utf8(view_layer->name, newname, sizeof(view_layer->name));
STRNCPY_UTF8(view_layer->name, newname);
BLI_uniquename(&scene->view_layers,
view_layer,
DATA_("ViewLayer"),
@ -570,7 +570,7 @@ void BKE_view_layer_rename(Main *bmain, Scene *scene, ViewLayer *view_layer, con
for (node = static_cast<bNode *>(scene->nodetree->nodes.first); node; node = node->next) {
if (node->type == CMP_NODE_R_LAYERS && node->id == nullptr) {
if (node->custom1 == index) {
BLI_strncpy(node->name, view_layer->name, NODE_MAXSTR);
STRNCPY(node->name, view_layer->name);
}
}
}
@ -2522,7 +2522,7 @@ ViewLayerAOV *BKE_view_layer_add_aov(ViewLayer *view_layer)
ViewLayerAOV *aov;
aov = MEM_cnew<ViewLayerAOV>(__func__);
aov->type = AOV_TYPE_COLOR;
BLI_strncpy(aov->name, DATA_("AOV"), sizeof(aov->name));
STRNCPY(aov->name, DATA_("AOV"));
BLI_addtail(&view_layer->aovs, aov);
viewlayer_aov_active_set(view_layer, aov);
viewlayer_aov_make_name_unique(view_layer);
@ -2643,10 +2643,10 @@ ViewLayerLightgroup *BKE_view_layer_add_lightgroup(ViewLayer *view_layer, const
ViewLayerLightgroup *lightgroup;
lightgroup = MEM_cnew<ViewLayerLightgroup>(__func__);
if (name && name[0]) {
BLI_strncpy(lightgroup->name, name, sizeof(lightgroup->name));
STRNCPY(lightgroup->name, name);
}
else {
BLI_strncpy(lightgroup->name, DATA_("Lightgroup"), sizeof(lightgroup->name));
STRNCPY(lightgroup->name, DATA_("Lightgroup"));
}
BLI_addtail(&view_layer->lightgroups, lightgroup);
viewlayer_lightgroup_active_set(view_layer, lightgroup);
@ -2690,8 +2690,8 @@ void BKE_view_layer_rename_lightgroup(Scene *scene,
const char *name)
{
char old_name[64];
BLI_strncpy_utf8(old_name, lightgroup->name, sizeof(old_name));
BLI_strncpy_utf8(lightgroup->name, name, sizeof(lightgroup->name));
STRNCPY_UTF8(old_name, lightgroup->name);
STRNCPY_UTF8(lightgroup->name, name);
viewlayer_lightgroup_make_name_unique(view_layer, lightgroup);
if (scene != nullptr) {
@ -2700,7 +2700,7 @@ void BKE_view_layer_rename_lightgroup(Scene *scene,
if (!ID_IS_LINKED(ob) && ob->lightgroup != nullptr) {
LightgroupMembership *lgm = ob->lightgroup;
if (STREQ(lgm->name, old_name)) {
BLI_strncpy_utf8(lgm->name, lightgroup->name, sizeof(lgm->name));
STRNCPY_UTF8(lgm->name, lightgroup->name);
}
}
}
@ -2711,7 +2711,7 @@ void BKE_view_layer_rename_lightgroup(Scene *scene,
scene->world->lightgroup != nullptr) {
LightgroupMembership *lgm = scene->world->lightgroup;
if (STREQ(lgm->name, old_name)) {
BLI_strncpy_utf8(lgm->name, lightgroup->name, sizeof(lgm->name));
STRNCPY_UTF8(lgm->name, lightgroup->name);
}
}
}

View File

@ -60,7 +60,7 @@ TEST(view_layer, aov_unique_names)
EXPECT_TRUE(STREQ(aov2->name, "AOV_001"));
/* Revert previous resolution */
BLI_strncpy(aov2->name, "AOV", MAX_NAME);
STRNCPY(aov2->name, "AOV");
BKE_view_layer_verify_aov(engine, &scene, view_layer);
EXPECT_TRUE(BKE_view_layer_has_valid_aov(view_layer));
EXPECT_FALSE((aov1->flag & AOV_CONFLICT) != 0);
@ -97,7 +97,7 @@ static void test_render_pass_conflict(Scene *scene,
RNA_boolean_set(&ptr, rna_prop_name, false);
/* Rename to Conflicting name */
BLI_strncpy(aov->name, render_pass_name, MAX_NAME);
STRNCPY(aov->name, render_pass_name);
BKE_view_layer_verify_aov(engine, scene, view_layer);
EXPECT_TRUE(BKE_view_layer_has_valid_aov(view_layer));
EXPECT_FALSE((aov->flag & AOV_CONFLICT) != 0);

View File

@ -1361,7 +1361,7 @@ void BKE_libblock_copy_ex(Main *bmain, const ID *id, ID **r_newid, const int ori
if ((flag & LIB_ID_CREATE_NO_ALLOCATE) != 0) {
/* r_newid already contains pointer to allocated memory. */
/* TODO: do we want to memset(0) whole mem before filling it? */
BLI_strncpy(new_id->name, id->name, sizeof(new_id->name));
STRNCPY(new_id->name, id->name);
new_id->us = 0;
new_id->tag |= LIB_TAG_NOT_ALLOCATED | LIB_TAG_NO_MAIN | LIB_TAG_NO_USER_REFCOUNT;
/* TODO: Do we want/need to copy more from ID struct itself? */
@ -1597,11 +1597,11 @@ bool BKE_id_new_name_validate(
tname = id->name + 2;
}
/* Make a copy of given name (tname args can be const). */
BLI_strncpy(name, tname, sizeof(name));
STRNCPY(name, tname);
if (name[0] == '\0') {
/* Disallow empty names. */
BLI_strncpy(name, DATA_(BKE_idtype_idcode_to_name(GS(id->name))), sizeof(name));
STRNCPY(name, DATA_(BKE_idtype_idcode_to_name(GS(id->name))));
}
else {
/* disallow non utf8 chars,

View File

@ -39,8 +39,8 @@ TEST(lib_id_remapper, mapped)
ID id1;
ID id2;
ID *idp = &id1;
BLI_strncpy(id1.name, "OB1", sizeof(id1.name));
BLI_strncpy(id2.name, "OB2", sizeof(id2.name));
STRNCPY(id1.name, "OB1");
STRNCPY(id2.name, "OB2");
IDRemapper *remapper = BKE_id_remapper_create();
BKE_id_remapper_add(remapper, &id1, &id2);
@ -55,7 +55,7 @@ TEST(lib_id_remapper, unassigned)
{
ID id1;
ID *idp = &id1;
BLI_strncpy(id1.name, "OB2", sizeof(id1.name));
STRNCPY(id1.name, "OB2");
IDRemapper *remapper = BKE_id_remapper_create();
BKE_id_remapper_add(remapper, &id1, nullptr);
@ -73,9 +73,9 @@ TEST(lib_id_remapper, unassign_when_mapped_to_self)
ID id2;
ID *idp;
BLI_strncpy(id_self.name, "OBSelf", sizeof(id1.name));
BLI_strncpy(id1.name, "OB1", sizeof(id1.name));
BLI_strncpy(id2.name, "OB2", sizeof(id2.name));
STRNCPY(id_self.name, "OBSelf");
STRNCPY(id1.name, "OB1");
STRNCPY(id2.name, "OB2");
/* Default mapping behavior. Should just remap to id2. */
idp = &id1;

View File

@ -4323,7 +4323,7 @@ void BKE_lib_override_library_update(Main *bmain, ID *local)
* different from reference linked ID. But local ID names need to be unique in a given type
* list of Main, so we cannot always keep it identical, which is why we need this special
* manual handling here. */
BLI_strncpy(tmp_id->name, local->name, sizeof(tmp_id->name));
STRNCPY(tmp_id->name, local->name);
/* Those ugly loop-back pointers again. Luckily we only need to deal with the shape keys here,
* collections' parents are fully runtime and reconstructed later. */
@ -4333,7 +4333,7 @@ void BKE_lib_override_library_update(Main *bmain, ID *local)
tmp_key->id.flag |= (local_key->id.flag & LIB_EMBEDDED_DATA_LIB_OVERRIDE);
BKE_main_namemap_remove_name(bmain, &tmp_key->id, tmp_key->id.name + 2);
tmp_key->id.lib = local_key->id.lib;
BLI_strncpy(tmp_key->id.name, local_key->id.name, sizeof(tmp_key->id.name));
STRNCPY(tmp_key->id.name, local_key->id.name);
}
PointerRNA rnaptr_src, rnaptr_dst, rnaptr_storage_stack, *rnaptr_storage = nullptr;

View File

@ -113,10 +113,10 @@ void BKE_library_filepath_set(Main *bmain, Library *lib, const char *filepath)
/* in some cases this is used to update the absolute path from the
* relative */
if (lib->filepath != filepath) {
BLI_strncpy(lib->filepath, filepath, sizeof(lib->filepath));
STRNCPY(lib->filepath, filepath);
}
BLI_strncpy(lib->filepath_abs, filepath, sizeof(lib->filepath_abs));
STRNCPY(lib->filepath_abs, filepath);
/* Not essential but set `filepath_abs` is an absolute copy of value which
* is more useful if its kept in sync. */

View File

@ -815,7 +815,7 @@ static LineStyleModifier *new_modifier(const char *name, int type, size_t size)
}
m = (LineStyleModifier *)MEM_callocN(size, "line style modifier");
m->type = type;
BLI_strncpy(m->name, name, sizeof(m->name));
STRNCPY(m->name, name);
m->influence = 1.0f;
m->flags = LS_MODIFIER_ENABLED | LS_MODIFIER_EXPANDED;

View File

@ -377,8 +377,8 @@ static LibWeakRefKey *lib_weak_key_create(LibWeakRefKey *key,
if (key == NULL) {
key = MEM_mallocN(sizeof(*key), __func__);
}
BLI_strncpy(key->filepath, lib_path, sizeof(key->filepath));
BLI_strncpy(key->id_name, id_name, sizeof(key->id_name));
STRNCPY(key->filepath, lib_path);
STRNCPY(key->id_name, id_name);
return key;
}
@ -463,12 +463,8 @@ void BKE_main_library_weak_reference_add_item(GHash *library_weak_reference_mapp
BLI_assert(!already_exist_in_mapping);
UNUSED_VARS_NDEBUG(already_exist_in_mapping);
BLI_strncpy(new_id->library_weak_reference->library_filepath,
library_filepath,
sizeof(new_id->library_weak_reference->library_filepath));
BLI_strncpy(new_id->library_weak_reference->library_id_name,
library_id_name,
sizeof(new_id->library_weak_reference->library_id_name));
STRNCPY(new_id->library_weak_reference->library_filepath, library_filepath);
STRNCPY(new_id->library_weak_reference->library_id_name, library_id_name);
*id_p = new_id;
}

View File

@ -47,7 +47,7 @@ using namespace blender;
static bool id_name_final_build(char *name, char *base_name, size_t base_name_len, int number)
{
char number_str[11]; /* Dot + nine digits + NULL terminator. */
size_t number_str_len = BLI_snprintf_rlen(number_str, ARRAY_SIZE(number_str), ".%.3d", number);
size_t number_str_len = SNPRINTF_RLEN(number_str, ".%.3d", number);
/* If the number would lead to an overflow of the maximum ID name length, we need to truncate
* the base name part and do all the number checks again. */
@ -229,7 +229,7 @@ static void main_namemap_populate(UniqueName_Map *name_map, struct Main *bmain,
/* Insert the full name into the set. */
UniqueName_Key key;
BLI_strncpy(key.name, id->name + 2, MAX_NAME);
STRNCPY(key.name, id->name + 2);
type_map->full_names.add(key);
/* Get the name and number parts ("name.number"). */
@ -279,7 +279,7 @@ bool BKE_main_namemap_get_name(struct Main *bmain, struct ID *id, char *name)
UniqueName_Key key;
while (true) {
/* Check if the full original name has a duplicate. */
BLI_strncpy(key.name, name, MAX_NAME);
STRNCPY(key.name, name);
const bool has_dup = type_map->full_names.contains(key);
/* Get the name and number parts ("name.number"). */
@ -299,7 +299,7 @@ bool BKE_main_namemap_get_name(struct Main *bmain, struct ID *id, char *name)
val.mark_used(number);
if (!has_dup) {
BLI_strncpy(key.name, name, MAX_NAME);
STRNCPY(key.name, name);
type_map->full_names.add(key);
}
return is_name_changed;
@ -334,7 +334,7 @@ bool BKE_main_namemap_get_name(struct Main *bmain, struct ID *id, char *name)
BLI_assert(number_to_use >= MIN_NUMBER);
if (id_name_final_build(name, key.name, base_name_len, number_to_use)) {
/* All good, add final name to the set. */
BLI_strncpy(key.name, name, MAX_NAME);
STRNCPY(key.name, name);
type_map->full_names.add(key);
break;
}
@ -369,7 +369,7 @@ void BKE_main_namemap_remove_name(struct Main *bmain, struct ID *id, const char
UniqueName_Key key;
/* Remove full name from the set. */
BLI_strncpy(key.name, name, MAX_NAME);
STRNCPY(key.name, name);
type_map->full_names.remove(key);
int number = MIN_NUMBER;
@ -408,7 +408,7 @@ static bool main_namemap_validate_and_fix(Main *bmain, const bool do_fix)
FOREACH_MAIN_LISTBASE_BEGIN (bmain, lb_iter) {
LISTBASE_FOREACH_MUTABLE (ID *, id_iter, lb_iter) {
Uniqueness_Key key;
BLI_strncpy(key.name, id_iter->name, MAX_ID_NAME);
STRNCPY(key.name, id_iter->name);
key.lib = id_iter->lib;
if (!id_names_libs.add(key)) {
is_valid = false;
@ -421,7 +421,7 @@ static bool main_namemap_validate_and_fix(Main *bmain, const bool do_fix)
* not really an issue. */
BKE_id_new_name_validate(
bmain, which_libbase(bmain, GS(id_iter->name)), id_iter, nullptr, true);
BLI_strncpy(key.name, id_iter->name, MAX_ID_NAME);
STRNCPY(key.name, id_iter->name);
if (!id_names_libs.add(key)) {
CLOG_ERROR(&LOG,
"\tID has been renamed to '%s', but it still seems to be already in use",
@ -442,7 +442,7 @@ static bool main_namemap_validate_and_fix(Main *bmain, const bool do_fix)
UniqueName_Key key_namemap;
/* Remove full name from the set. */
BLI_strncpy(key_namemap.name, id_iter->name + 2, MAX_NAME);
STRNCPY(key_namemap.name, id_iter->name + 2);
if (!type_map->full_names.contains(key_namemap)) {
is_valid = false;
CLOG_ERROR(&LOG,

View File

@ -336,7 +336,7 @@ MaskLayer *BKE_mask_layer_new(Mask *mask, const char *name)
MaskLayer *masklay = MEM_cnew<MaskLayer>(__func__);
if (name && name[0]) {
BLI_strncpy(masklay->name, name, sizeof(masklay->name));
STRNCPY(masklay->name, name);
}
else {
strcpy(masklay->name, DATA_("MaskLayer"));
@ -389,7 +389,7 @@ void BKE_mask_layer_unique_name(Mask *mask, MaskLayer *masklay)
void BKE_mask_layer_rename(Mask *mask, MaskLayer *masklay, char *oldname, char *newname)
{
BLI_strncpy(masklay->name, newname, sizeof(masklay->name));
STRNCPY(masklay->name, newname);
BKE_mask_layer_unique_name(mask, masklay);
@ -401,7 +401,7 @@ MaskLayer *BKE_mask_layer_copy(const MaskLayer *masklay)
{
MaskLayer *masklay_new = MEM_cnew<MaskLayer>("new mask layer");
BLI_strncpy(masklay_new->name, masklay->name, sizeof(masklay_new->name));
STRNCPY(masklay_new->name, masklay->name);
masklay_new->alpha = masklay->alpha;
masklay_new->blend = masklay->blend;
@ -1011,7 +1011,7 @@ Mask *BKE_mask_new(Main *bmain, const char *name)
char mask_name[MAX_ID_NAME - 2];
if (name && name[0]) {
BLI_strncpy(mask_name, name, sizeof(mask_name));
STRNCPY(mask_name, name);
}
else {
strcpy(mask_name, "Mask");

View File

@ -770,7 +770,7 @@ static Mesh *mesh_new_from_mesh(Object *object, Mesh *mesh)
nullptr, &mesh->id, nullptr, LIB_ID_CREATE_NO_MAIN | LIB_ID_CREATE_NO_USER_REFCOUNT);
/* NOTE: Materials should already be copied. */
/* Copy original mesh name. This is because edit meshes might not have one properly set name. */
BLI_strncpy(mesh_result->id.name, ((ID *)object->data)->name, sizeof(mesh_result->id.name));
STRNCPY(mesh_result->id.name, ((ID *)object->data)->name);
return mesh_result;
}

View File

@ -137,7 +137,7 @@ static ModifierData *modifier_allocate_and_init(ModifierType type)
ModifierData *md = static_cast<ModifierData *>(MEM_callocN(mti->structSize, mti->structName));
/* NOTE: this name must be made unique later. */
BLI_strncpy(md->name, DATA_(mti->name), sizeof(md->name));
STRNCPY(md->name, DATA_(mti->name));
md->type = type;
md->mode = eModifierMode_Realtime | eModifierMode_Render;
@ -329,7 +329,7 @@ ModifierData *BKE_modifier_copy_ex(const ModifierData *md, int flag)
{
ModifierData *md_dst = modifier_allocate_and_init(ModifierType(md->type));
BLI_strncpy(md_dst->name, md->name, sizeof(md_dst->name));
STRNCPY(md_dst->name, md->name);
BKE_modifier_copydata_ex(md, md_dst, flag);
return md_dst;

View File

@ -518,10 +518,10 @@ static void get_proxy_filepath(const MovieClip *clip,
BLI_path_split_dir_file(clip->filepath, clipdir, FILE_MAX, clipfile, FILE_MAX);
if (clip->flag & MCLIP_USE_PROXY_CUSTOM_DIR) {
BLI_strncpy(dir, clip->proxy.dir, sizeof(dir));
STRNCPY(dir, clip->proxy.dir);
}
else {
BLI_snprintf(dir, sizeof(dir), "%s" SEP_STR "BL_proxy", clipdir);
SNPRINTF(dir, "%s" SEP_STR "BL_proxy", clipdir);
}
if (undistorted) {
@ -671,7 +671,7 @@ static void movieclip_open_anim_file(MovieClip *clip)
char str[FILE_MAX];
if (!clip->anim) {
BLI_strncpy(str, clip->filepath, FILE_MAX);
STRNCPY(str, clip->filepath);
BLI_path_abs(str, ID_BLEND_PATH_FROM_GLOBAL(&clip->id));
/* FIXME: make several stream accessible in image editor, too */
@ -680,7 +680,7 @@ static void movieclip_open_anim_file(MovieClip *clip)
if (clip->anim) {
if (clip->flag & MCLIP_USE_PROXY_CUSTOM_DIR) {
char dir[FILE_MAX];
BLI_strncpy(dir, clip->proxy.dir, sizeof(dir));
STRNCPY(dir, clip->proxy.dir);
BLI_path_abs(dir, BKE_main_blendfile_path_from_global());
IMB_anim_set_index_dir(clip->anim, dir);
}
@ -935,7 +935,7 @@ static bool put_imbuf_cache(
struct MovieCache *moviecache;
// char cache_name[64];
// BLI_snprintf(cache_name, sizeof(cache_name), "movie %s", clip->id.name);
// SNPRINTF(cache_name, "movie %s", clip->id.name);
clip->cache = MEM_callocN(sizeof(MovieClipCache), "movieClipCache");
@ -1018,7 +1018,7 @@ static void detect_clip_source(Main *bmain, MovieClip *clip)
ImBuf *ibuf;
char filepath[FILE_MAX];
BLI_strncpy(filepath, clip->filepath, sizeof(filepath));
STRNCPY(filepath, clip->filepath);
BLI_path_abs(filepath, BKE_main_blendfile_path(bmain));
ibuf = IMB_testiffname(filepath, IB_rect | IB_multilayer);
@ -1037,7 +1037,7 @@ MovieClip *BKE_movieclip_file_add(Main *bmain, const char *filepath)
int file;
char str[FILE_MAX];
BLI_strncpy(str, filepath, sizeof(str));
STRNCPY(str, filepath);
BLI_path_abs(str, BKE_main_blendfile_path(bmain));
/* exists? */
@ -1051,7 +1051,7 @@ MovieClip *BKE_movieclip_file_add(Main *bmain, const char *filepath)
/* create a short library name */
clip = movieclip_alloc(bmain, BLI_path_basename(filepath));
BLI_strncpy(clip->filepath, filepath, sizeof(clip->filepath));
STRNCPY(clip->filepath, filepath);
detect_clip_source(bmain, clip);
@ -1072,12 +1072,12 @@ MovieClip *BKE_movieclip_file_add_exists_ex(Main *bmain, const char *filepath, b
MovieClip *clip;
char str[FILE_MAX], strtest[FILE_MAX];
BLI_strncpy(str, filepath, sizeof(str));
STRNCPY(str, filepath);
BLI_path_abs(str, BKE_main_blendfile_path(bmain));
/* first search an identical filepath */
for (clip = bmain->movieclips.first; clip; clip = clip->id.next) {
BLI_strncpy(strtest, clip->filepath, sizeof(clip->filepath));
STRNCPY(strtest, clip->filepath);
BLI_path_abs(strtest, ID_BLEND_PATH(bmain, &clip->id));
if (BLI_path_cmp(strtest, str) == 0) {

View File

@ -517,7 +517,7 @@ NlaStrip *BKE_nlastack_add_strip(AnimData *adt, bAction *act, const bool is_libo
nlt = BKE_nlatrack_new_tail(&adt->nla_tracks, is_liboverride);
BKE_nlatrack_set_active(&adt->nla_tracks, nlt);
BKE_nlatrack_add_strip(nlt, strip, is_liboverride);
BLI_strncpy(nlt->name, act->id.name + 2, sizeof(nlt->name));
STRNCPY(nlt->name, act->id.name + 2);
}
/* automatically name it too */
@ -1798,18 +1798,16 @@ void BKE_nlastrip_validate_name(AnimData *adt, NlaStrip *strip)
if (strip->name[0] == 0) {
switch (strip->type) {
case NLASTRIP_TYPE_CLIP: /* act-clip */
BLI_strncpy(strip->name,
(strip->act) ? (strip->act->id.name + 2) : ("<No Action>"),
sizeof(strip->name));
STRNCPY(strip->name, (strip->act) ? (strip->act->id.name + 2) : ("<No Action>"));
break;
case NLASTRIP_TYPE_TRANSITION: /* transition */
BLI_strncpy(strip->name, "Transition", sizeof(strip->name));
STRNCPY(strip->name, "Transition");
break;
case NLASTRIP_TYPE_META: /* meta */
BLI_strncpy(strip->name, "Meta", sizeof(strip->name));
STRNCPY(strip->name, "Meta");
break;
default:
BLI_strncpy(strip->name, "NLA Strip", sizeof(strip->name));
STRNCPY(strip->name, "NLA Strip");
break;
}
}
@ -2066,7 +2064,7 @@ bool BKE_nla_action_stash(AnimData *adt, const bool is_liboverride)
BLI_addhead(&adt->nla_tracks, nlt);
}
BLI_strncpy(nlt->name, STASH_TRACK_NAME, sizeof(nlt->name));
STRNCPY(nlt->name, STASH_TRACK_NAME);
BLI_uniquename(
&adt->nla_tracks, nlt, STASH_TRACK_NAME, '.', offsetof(NlaTrack, name), sizeof(nlt->name));

View File

@ -1159,7 +1159,7 @@ static void node_init(const bContext *C, bNodeTree *ntree, bNode *node)
* Data have their own translation option!
* This solution may be a bit rougher than nodeLabel()'s returned string, but it's simpler
* than adding "do_translate" flags to this func (and labelfunc() as well). */
BLI_strncpy(node->name, DATA_(ntype->ui_name), NODE_MAXSTR);
STRNCPY(node->name, DATA_(ntype->ui_name));
nodeUniqueName(ntree, node);
/* Generally sockets should be added after the initialization, because the set of sockets might
@ -1596,11 +1596,11 @@ static bNodeSocket *make_socket(bNodeTree *ntree,
if (identifier && identifier[0] != '\0') {
/* use explicit identifier */
BLI_strncpy(auto_identifier, identifier, sizeof(auto_identifier));
STRNCPY(auto_identifier, identifier);
}
else {
/* if no explicit identifier is given, assign a unique identifier based on the name */
BLI_strncpy(auto_identifier, name, sizeof(auto_identifier));
STRNCPY(auto_identifier, name);
}
/* Make the identifier unique. */
BLI_uniquename_cb(
@ -1610,15 +1610,15 @@ static bNodeSocket *make_socket(bNodeTree *ntree,
sock->runtime = MEM_new<bNodeSocketRuntime>(__func__);
sock->in_out = in_out;
BLI_strncpy(sock->identifier, auto_identifier, NODE_MAXSTR);
STRNCPY(sock->identifier, auto_identifier);
sock->limit = (in_out == SOCK_IN ? 1 : 0xFFF);
BLI_strncpy(sock->name, name, NODE_MAXSTR);
STRNCPY(sock->name, name);
sock->storage = nullptr;
sock->flag |= SOCK_COLLAPSED;
sock->type = SOCK_CUSTOM; /* int type undefined by default */
BLI_strncpy(sock->idname, idname, sizeof(sock->idname));
STRNCPY(sock->idname, idname);
node_socket_set_typeinfo(ntree, sock, nodeSocketTypeFind(idname));
return sock;
@ -1772,7 +1772,7 @@ void nodeModifySocketType(bNodeTree *ntree,
}
}
BLI_strncpy(sock->idname, idname, sizeof(sock->idname));
STRNCPY(sock->idname, idname);
node_socket_set_typeinfo(ntree, sock, socktype);
}
@ -2327,7 +2327,7 @@ bNode *nodeAddNode(const bContext *C, bNodeTree *ntree, const char *idname)
BLI_addtail(&ntree->nodes, node);
nodeUniqueID(ntree, node);
BLI_strncpy(node->idname, idname, sizeof(node->idname));
STRNCPY(node->idname, idname);
node_set_typeinfo(C, ntree, node, nodeTypeFind(idname));
BKE_ntree_update_tag_node_new(ntree, node);
@ -2898,7 +2898,7 @@ static bNodeTree *ntreeAddTree_do(
BLI_assert(owner_id == nullptr);
}
BLI_strncpy(ntree->idname, idname, sizeof(ntree->idname));
STRNCPY(ntree->idname, idname);
ntree_set_typeinfo(ntree, ntreeTypeFind(idname));
return ntree;
@ -3283,7 +3283,7 @@ void nodeRemoveNode(Main *bmain, bNodeTree *ntree, bNode *node, const bool do_id
char prefix[MAX_IDPROP_NAME * 2];
BLI_str_escape(propname_esc, node->name, sizeof(propname_esc));
BLI_snprintf(prefix, sizeof(prefix), "nodes[\"%s\"]", propname_esc);
SNPRINTF(prefix, "nodes[\"%s\"]", propname_esc);
if (BKE_animdata_fix_paths_remove(&ntree->id, prefix)) {
if (bmain != nullptr) {
@ -3538,7 +3538,7 @@ static bNodeSocket *make_socket_interface(bNodeTree *ntree,
bNodeSocket *sock = MEM_cnew<bNodeSocket>("socket template");
sock->runtime = MEM_new<bNodeSocketRuntime>(__func__);
BLI_strncpy(sock->idname, stype->idname, sizeof(sock->idname));
STRNCPY(sock->idname, stype->idname);
sock->in_out = int(in_out);
sock->type = int(SOCK_CUSTOM); /* int type undefined by default */
node_socket_set_typeinfo(ntree, sock, stype);
@ -3547,15 +3547,15 @@ static bNodeSocket *make_socket_interface(bNodeTree *ntree,
const int own_index = ntree->cur_index++;
/* use the own_index as socket identifier */
if (in_out == SOCK_IN) {
BLI_snprintf(sock->identifier, MAX_NAME, "Input_%d", own_index);
SNPRINTF(sock->identifier, "Input_%d", own_index);
}
else {
BLI_snprintf(sock->identifier, MAX_NAME, "Output_%d", own_index);
SNPRINTF(sock->identifier, "Output_%d", own_index);
}
sock->limit = (in_out == SOCK_IN ? 1 : 0xFFF);
BLI_strncpy(sock->name, name, NODE_MAXSTR);
STRNCPY(sock->name, name);
sock->storage = nullptr;
sock->flag |= SOCK_COLLAPSED;
@ -4158,7 +4158,7 @@ void node_type_base(bNodeType *ntype, const int type, const char *name, const sh
*/
#define DefNode(Category, ID, DefFunc, EnumName, StructName, UIName, UIDesc) \
case ID: \
BLI_strncpy(ntype->idname, #Category #StructName, sizeof(ntype->idname)); \
STRNCPY(ntype->idname, #Category #StructName); \
ntype->rna_ext.srna = RNA_struct_find(#Category #StructName); \
BLI_assert(ntype->rna_ext.srna != nullptr); \
RNA_struct_blender_type_set(ntype->rna_ext.srna, ntype); \
@ -4172,7 +4172,7 @@ void node_type_base(bNodeType *ntype, const int type, const char *name, const sh
BLI_assert(ntype->idname[0] != '\0');
ntype->type = type;
BLI_strncpy(ntype->ui_name, name, sizeof(ntype->ui_name));
STRNCPY(ntype->ui_name, name);
ntype->nclass = nclass;
node_type_base_defaults(ntype);
@ -4186,9 +4186,9 @@ void node_type_base_custom(bNodeType *ntype,
const char *name,
const short nclass)
{
BLI_strncpy(ntype->idname, idname, sizeof(ntype->idname));
STRNCPY(ntype->idname, idname);
ntype->type = NODE_CUSTOM;
BLI_strncpy(ntype->ui_name, name, sizeof(ntype->ui_name));
STRNCPY(ntype->ui_name, name);
ntype->nclass = nclass;
node_type_base_defaults(ntype);
@ -4247,7 +4247,7 @@ void node_type_socket_templates(bNodeType *ntype,
}
for (bNodeSocketTemplate *ntemp = inputs; ntemp->type >= 0; ntemp++) {
BLI_strncpy(ntemp->identifier, ntemp->name, sizeof(ntemp->identifier));
STRNCPY(ntemp->identifier, ntemp->name);
unique_socket_template_identifier(inputs, ntemp, ntemp->identifier, '_');
}
}
@ -4258,7 +4258,7 @@ void node_type_socket_templates(bNodeType *ntype,
}
for (bNodeSocketTemplate *ntemp = outputs; ntemp->type >= 0; ntemp++) {
BLI_strncpy(ntemp->identifier, ntemp->name, sizeof(ntemp->identifier));
STRNCPY(ntemp->identifier, ntemp->name);
unique_socket_template_identifier(outputs, ntemp, ntemp->identifier, '_');
}
}
@ -4302,7 +4302,7 @@ void node_type_storage(bNodeType *ntype,
const bNode *src_node))
{
if (storagename) {
BLI_strncpy(ntype->storagename, storagename, sizeof(ntype->storagename));
STRNCPY(ntype->storagename, storagename);
}
else {
ntype->storagename[0] = '\0';

View File

@ -216,7 +216,7 @@ static void object_copy_data(Main *bmain, ID *id_dst, const ID *id_src, const in
BLI_listbase_clear(&ob_dst->shader_fx);
LISTBASE_FOREACH (ShaderFxData *, fx, &ob_src->shader_fx) {
ShaderFxData *nfx = BKE_shaderfx_new(fx->type);
BLI_strncpy(nfx->name, fx->name, sizeof(nfx->name));
STRNCPY(nfx->name, fx->name);
BKE_shaderfx_copydata_ex(fx, nfx, flag_subdata);
BLI_addtail(&ob_dst->shader_fx, nfx);
}
@ -1574,7 +1574,7 @@ bool BKE_object_copy_modifier(
else {
md_dst = BKE_modifier_new(md_src->type);
BLI_strncpy(md_dst->name, md_src->name, sizeof(md_dst->name));
STRNCPY(md_dst->name, md_src->name);
if (md_src->type == eModifierType_Multires) {
/* Has to be done after mod creation, but *before* we actually copy its settings! */
@ -1618,7 +1618,7 @@ bool BKE_object_copy_gpencil_modifier(struct Object *ob_dst, GpencilModifierData
BLI_assert(ob_dst->type == OB_GPENCIL_LEGACY);
GpencilModifierData *gmd_dst = BKE_gpencil_modifier_new(gmd_src->type);
BLI_strncpy(gmd_dst->name, gmd_src->name, sizeof(gmd_dst->name));
STRNCPY(gmd_dst->name, gmd_src->name);
const GpencilModifierTypeInfo *mti = BKE_gpencil_modifier_get_info(
(GpencilModifierType)gmd_src->type);
@ -1663,7 +1663,7 @@ bool BKE_object_modifier_stack_copy(Object *ob_dst,
LISTBASE_FOREACH (GpencilModifierData *, gmd_src, &ob_src->greasepencil_modifiers) {
GpencilModifierData *gmd_dst = BKE_gpencil_modifier_new(gmd_src->type);
BLI_strncpy(gmd_dst->name, gmd_src->name, sizeof(gmd_dst->name));
STRNCPY(gmd_dst->name, gmd_src->name);
BKE_gpencil_modifier_copydata_ex(gmd_src, gmd_dst, flag_subdata);
BLI_addtail(&ob_dst->greasepencil_modifiers, gmd_dst);
}
@ -3595,7 +3595,7 @@ void BKE_object_workob_calc_parent(Depsgraph *depsgraph, Scene *scene, Object *o
* object's local loc/rot/scale instead of after. For example, a "Copy Rotation" constraint would
* rotate the object's local translation as well. See #82156. */
BLI_strncpy(workob->parsubstr, ob->parsubstr, sizeof(workob->parsubstr));
STRNCPY(workob->parsubstr, ob->parsubstr);
BKE_object_where_is_calc(depsgraph, scene, workob);
}

View File

@ -100,7 +100,7 @@ bFaceMap *BKE_object_facemap_add_name(Object *ob, const char *name)
fmap = MEM_callocN(sizeof(bFaceMap), __func__);
BLI_strncpy(fmap->name, name, sizeof(fmap->name));
STRNCPY(fmap->name, name);
BLI_addtail(&ob->fmaps, fmap);

View File

@ -191,7 +191,7 @@ PackedFile *BKE_packedfile_new(ReportList *reports, const char *filepath_rel, co
/* convert relative filenames to absolute filenames */
BLI_strncpy(filepath, filepath_rel, sizeof(filepath));
STRNCPY(filepath, filepath_rel);
BLI_path_abs(filepath, basepath);
/* open the file
@ -299,12 +299,12 @@ int BKE_packedfile_write_to_file(ReportList *reports,
if (guimode) {
} // XXX waitcursor(1);
BLI_strncpy(filepath, filepath_rel, sizeof(filepath));
STRNCPY(filepath, filepath_rel);
BLI_path_abs(filepath, ref_file_name);
if (BLI_exists(filepath)) {
for (number = 1; number <= 999; number++) {
BLI_snprintf(filepath_temp, sizeof(filepath_temp), "%s.%03d_", filepath, number);
SNPRINTF(filepath_temp, "%s.%03d_", filepath, number);
if (!BLI_exists(filepath_temp)) {
if (BLI_copy(filepath, filepath_temp) == RET_OK) {
remove_tmp = true;
@ -365,7 +365,7 @@ enum ePF_FileCompare BKE_packedfile_compare_to_file(const char *ref_file_name,
char buf[4096];
char filepath[FILE_MAX];
BLI_strncpy(filepath, filepath_rel, sizeof(filepath));
STRNCPY(filepath, filepath_rel);
BLI_path_abs(filepath, ref_file_name);
if (BLI_stat(filepath, &st) == -1) {
@ -429,7 +429,7 @@ char *BKE_packedfile_unpack_to_file(ReportList *reports,
case PF_USE_LOCAL: {
char temp_abs[FILE_MAX];
BLI_strncpy(temp_abs, local_name, sizeof(temp_abs));
STRNCPY(temp_abs, local_name);
BLI_path_abs(temp_abs, ref_file_name);
/* if file exists use it */
@ -448,7 +448,7 @@ char *BKE_packedfile_unpack_to_file(ReportList *reports,
case PF_USE_ORIGINAL: {
char temp_abs[FILE_MAX];
BLI_strncpy(temp_abs, abs_name, sizeof(temp_abs));
STRNCPY(temp_abs, abs_name);
BLI_path_abs(temp_abs, ref_file_name);
/* if file exists use it */
@ -494,7 +494,7 @@ static void unpack_generate_paths(const char *filepath,
if (temp_filename[0] == '\0') {
/* NOTE: we generally do not have any real way to re-create extension out of data. */
const size_t len = BLI_strncpy_rlen(temp_filename, id->name + 2, sizeof(temp_filename));
const size_t len = STRNCPY_RLEN(temp_filename, id->name + 2);
printf("%s\n", temp_filename);
/* For images ensure that the temporary filename contains tile number information as well as
@ -507,7 +507,7 @@ static void unpack_generate_paths(const char *filepath,
enum eImbFileType ftype = IMB_ispic_type_from_memory((const uchar *)pf->data, pf->size);
if (ima->source == IMA_SRC_TILED) {
char tile_number[6];
BLI_snprintf(tile_number, sizeof(tile_number), ".%d", imapf->tile_number);
SNPRINTF(tile_number, ".%d", imapf->tile_number);
BLI_strncpy(temp_filename + len, tile_number, sizeof(temp_filename) - len);
}
if (ftype != IMB_FTYPE_NONE) {
@ -523,7 +523,7 @@ static void unpack_generate_paths(const char *filepath,
if (temp_dirname[0] == '\0') {
/* Fallback to relative dir. */
BLI_strncpy(temp_dirname, "//", sizeof(temp_dirname));
STRNCPY(temp_dirname, "//");
}
{
@ -589,7 +589,7 @@ int BKE_packedfile_unpack_vfont(Main *bmain,
ret_value = RET_OK;
BKE_packedfile_free(vfont->packedfile);
vfont->packedfile = NULL;
BLI_strncpy(vfont->filepath, new_file_path, sizeof(vfont->filepath));
STRNCPY(vfont->filepath, new_file_path);
MEM_freeN(new_file_path);
}
}
@ -608,7 +608,7 @@ int BKE_packedfile_unpack_sound(Main *bmain,
char *new_file_path = BKE_packedfile_unpack(
bmain, reports, (ID *)sound, sound->filepath, sound->packedfile, how);
if (new_file_path != NULL) {
BLI_strncpy(sound->filepath, new_file_path, sizeof(sound->filepath));
STRNCPY(sound->filepath, new_file_path);
MEM_freeN(new_file_path);
BKE_packedfile_free(sound->packedfile);
@ -646,12 +646,12 @@ int BKE_packedfile_unpack_image(Main *bmain,
/* update the new corresponding view filepath */
iv = BLI_findstring(&ima->views, imapf->filepath, offsetof(ImageView, filepath));
if (iv) {
BLI_strncpy(iv->filepath, new_file_path, sizeof(imapf->filepath));
STRNCPY(iv->filepath, new_file_path);
}
/* keep the new name in the image for non-pack specific reasons */
if (how != PF_REMOVE) {
BLI_strncpy(ima->filepath, new_file_path, sizeof(imapf->filepath));
STRNCPY(ima->filepath, new_file_path);
if (ima->source == IMA_SRC_TILED) {
/* Ensure that the Image filepath is kept in a tokenized format. */
BKE_image_ensure_tile_token(ima->filepath, sizeof(ima->filepath));
@ -686,7 +686,7 @@ int BKE_packedfile_unpack_volume(Main *bmain,
char *new_file_path = BKE_packedfile_unpack(
bmain, reports, (ID *)volume, volume->filepath, volume->packedfile, how);
if (new_file_path != NULL) {
BLI_strncpy(volume->filepath, new_file_path, sizeof(volume->filepath));
STRNCPY(volume->filepath, new_file_path);
MEM_freeN(new_file_path);
BKE_packedfile_free(volume->packedfile);

View File

@ -2428,7 +2428,7 @@ static bool sculpt_attribute_create(SculptSession *ss,
out->params = *params;
out->proptype = proptype;
out->domain = domain;
BLI_strncpy_utf8(out->name, name, sizeof(out->name));
STRNCPY_UTF8(out->name, name);
/* Force non-CustomData simple_array mode if not PBVH_FACES. */
if (pbvhtype == PBVH_GRIDS || (pbvhtype == PBVH_BMESH && flat_array_for_bmesh)) {
@ -2696,7 +2696,7 @@ SculptAttribute *BKE_sculpt_attribute_get(struct Object *ob,
attr->layer = cdata->layers + index;
attr->elem_size = CustomData_get_elem_size(attr->layer);
BLI_strncpy_utf8(attr->name, name, sizeof(attr->name));
STRNCPY_UTF8(attr->name, name);
return attr;
}
}

View File

@ -4020,7 +4020,7 @@ static ModifierData *object_add_or_copy_particle_system(
psys->part = BKE_particlesettings_add(bmain, DATA_("ParticleSettings"));
}
md = BKE_modifier_new(eModifierType_ParticleSystem);
BLI_strncpy(md->name, psys->name, sizeof(md->name));
STRNCPY(md->name, psys->name);
BKE_modifier_unique_name(&ob->modifiers, md);
psmd = (ParticleSystemModifierData *)md;

View File

@ -1288,7 +1288,7 @@ static int ptcache_frame_from_filename(const char *filename, const char *ext)
if (len > ext_len) {
/* using frame_len here gives compile error (vla) */
char num[/* frame_len */ 6 + 1];
BLI_strncpy(num, filename + len - ext_len, sizeof(num));
STRNCPY(num, filename + len - ext_len);
return atoi(num);
}
@ -3503,24 +3503,24 @@ void BKE_ptcache_disk_cache_rename(PTCacheID *pid, const char *name_src, const c
}
/* save old name */
BLI_strncpy(old_name, pid->cache->name, sizeof(old_name));
STRNCPY(old_name, pid->cache->name);
/* get "from" filename */
BLI_strncpy(pid->cache->name, name_src, sizeof(pid->cache->name));
STRNCPY(pid->cache->name, name_src);
len = ptcache_filepath(pid, old_filepath, 0, false, false); /* no path */
ptcache_path(pid, path);
dir = opendir(path);
if (dir == NULL) {
BLI_strncpy(pid->cache->name, old_name, sizeof(pid->cache->name));
STRNCPY(pid->cache->name, old_name);
return;
}
ptcache_filepath_ext_append(pid, ext, 0, false, 0);
/* put new name into cache */
BLI_strncpy(pid->cache->name, name_dst, sizeof(pid->cache->name));
STRNCPY(pid->cache->name, name_dst);
while ((de = readdir(dir)) != NULL) {
if (strstr(de->d_name, ext)) { /* Do we have the right extension? */
@ -3538,7 +3538,7 @@ void BKE_ptcache_disk_cache_rename(PTCacheID *pid, const char *name_src, const c
}
closedir(dir);
BLI_strncpy(pid->cache->name, old_name, sizeof(pid->cache->name));
STRNCPY(pid->cache->name, old_name);
}
void BKE_ptcache_load_external(PTCacheID *pid)
@ -3573,10 +3573,10 @@ void BKE_ptcache_load_external(PTCacheID *pid)
const char *fext = ptcache_file_extension(pid);
if (cache->index >= 0) {
BLI_snprintf(ext, sizeof(ext), "_%02d%s", cache->index, fext);
SNPRINTF(ext, "_%02d%s", cache->index, fext);
}
else {
BLI_strncpy(ext, fext, sizeof(ext));
STRNCPY(ext, fext);
}
while ((de = readdir(dir)) != NULL) {
@ -3674,13 +3674,13 @@ void BKE_ptcache_update_info(PTCacheID *pid)
/* smoke doesn't use frame 0 as info frame so can't check based on totpoint */
if (pid->type == PTCACHE_TYPE_SMOKE_DOMAIN && totframes) {
BLI_snprintf(cache->info, sizeof(cache->info), TIP_("%i frames found!"), totframes);
SNPRINTF(cache->info, TIP_("%i frames found!"), totframes);
}
else if (totframes && cache->totpoint) {
BLI_snprintf(cache->info, sizeof(cache->info), TIP_("%i points found!"), cache->totpoint);
SNPRINTF(cache->info, TIP_("%i points found!"), cache->totpoint);
}
else {
BLI_strncpy(cache->info, TIP_("No valid data to read!"), sizeof(cache->info));
STRNCPY(cache->info, TIP_("No valid data to read!"));
}
return;
}
@ -3690,11 +3690,10 @@ void BKE_ptcache_update_info(PTCacheID *pid)
int totpoint = pid->totpoint(pid->calldata, 0);
if (cache->totpoint > totpoint) {
BLI_snprintf(
mem_info, sizeof(mem_info), TIP_("%i cells + High Resolution cached"), totpoint);
SNPRINTF(mem_info, TIP_("%i cells + High Resolution cached"), totpoint);
}
else {
BLI_snprintf(mem_info, sizeof(mem_info), TIP_("%i cells cached"), totpoint);
SNPRINTF(mem_info, TIP_("%i cells cached"), totpoint);
}
}
else {
@ -3706,7 +3705,7 @@ void BKE_ptcache_update_info(PTCacheID *pid)
}
}
BLI_snprintf(mem_info, sizeof(mem_info), TIP_("%i frames on disk"), totframes);
SNPRINTF(mem_info, TIP_("%i frames on disk"), totframes);
}
}
else {
@ -3734,25 +3733,17 @@ void BKE_ptcache_update_info(PTCacheID *pid)
BLI_str_format_int_grouped(formatted_tot, totframes);
BLI_str_format_byte_unit(formatted_mem, bytes, false);
BLI_snprintf(mem_info,
sizeof(mem_info),
TIP_("%s frames in memory (%s)"),
formatted_tot,
formatted_mem);
SNPRINTF(mem_info, TIP_("%s frames in memory (%s)"), formatted_tot, formatted_mem);
}
if (cache->flag & PTCACHE_OUTDATED) {
BLI_snprintf(cache->info, sizeof(cache->info), TIP_("%s, cache is outdated!"), mem_info);
SNPRINTF(cache->info, TIP_("%s, cache is outdated!"), mem_info);
}
else if (cache->flag & PTCACHE_FRAMES_SKIPPED) {
BLI_snprintf(cache->info,
sizeof(cache->info),
TIP_("%s, not exact since frame %i"),
mem_info,
cache->last_exact);
SNPRINTF(cache->info, TIP_("%s, not exact since frame %i"), mem_info, cache->last_exact);
}
else {
BLI_snprintf(cache->info, sizeof(cache->info), "%s.", mem_info);
SNPRINTF(cache->info, "%s.", mem_info);
}
}

View File

@ -46,7 +46,7 @@ bUserAssetLibrary *BKE_preferences_asset_library_add(UserDef *userdef,
BKE_preferences_asset_library_name_set(userdef, library, name);
}
if (path) {
BLI_strncpy(library->path, path, sizeof(library->path));
STRNCPY(library->path, path);
}
return library;
@ -61,7 +61,7 @@ void BKE_preferences_asset_library_name_set(UserDef *userdef,
bUserAssetLibrary *library,
const char *name)
{
BLI_strncpy_utf8(library->name, name, sizeof(library->name));
STRNCPY_UTF8(library->name, name);
BLI_uniquename(&userdef->asset_libraries,
library,
name,
@ -72,7 +72,7 @@ void BKE_preferences_asset_library_name_set(UserDef *userdef,
void BKE_preferences_asset_library_path_set(bUserAssetLibrary *library, const char *path)
{
BLI_strncpy(library->path, path, sizeof(library->path));
STRNCPY(library->path, path);
if (BLI_is_file(library->path)) {
BLI_path_parent_dir(library->path);
}

View File

@ -154,7 +154,7 @@ static void scene_init_data(ID *id)
MEMCPY_STRUCT_AFTER(scene, DNA_struct_default_get(Scene), id);
BLI_strncpy(scene->r.bake.filepath, U.renderdir, sizeof(scene->r.bake.filepath));
STRNCPY(scene->r.bake.filepath, U.renderdir);
mblur_shutter_curve = &scene->r.mblur_shutter_curve;
BKE_curvemapping_set_defaults(mblur_shutter_curve, 1, 0.0f, 0.0f, 1.0f, 1.0f);
@ -203,9 +203,9 @@ static void scene_init_data(ID *id)
pset->brush[PE_BRUSH_CUT].strength = 1.0f;
}
BLI_strncpy(scene->r.engine, RE_engine_id_BLENDER_EEVEE, sizeof(scene->r.engine));
STRNCPY(scene->r.engine, RE_engine_id_BLENDER_EEVEE);
BLI_strncpy(scene->r.pic, U.renderdir, sizeof(scene->r.pic));
STRNCPY(scene->r.pic, U.renderdir);
/* NOTE: in header_info.c the scene copy happens...,
* if you add more to renderdata it has to be checked there. */
@ -213,11 +213,11 @@ static void scene_init_data(ID *id)
/* multiview - stereo */
BKE_scene_add_render_view(scene, STEREO_LEFT_NAME);
srv = static_cast<SceneRenderView *>(scene->r.views.first);
BLI_strncpy(srv->suffix, STEREO_LEFT_SUFFIX, sizeof(srv->suffix));
STRNCPY(srv->suffix, STEREO_LEFT_SUFFIX);
BKE_scene_add_render_view(scene, STEREO_RIGHT_NAME);
srv = static_cast<SceneRenderView *>(scene->r.views.last);
BLI_strncpy(srv->suffix, STEREO_RIGHT_SUFFIX, sizeof(srv->suffix));
STRNCPY(srv->suffix, STEREO_RIGHT_SUFFIX);
BKE_sound_reset_scene_runtime(scene);
@ -227,9 +227,7 @@ static void scene_init_data(ID *id)
BKE_color_managed_display_settings_init(&scene->display_settings);
BKE_color_managed_view_settings_init_render(
&scene->view_settings, &scene->display_settings, "Filmic");
BLI_strncpy(scene->sequencer_colorspace_settings.name,
colorspace_name,
sizeof(scene->sequencer_colorspace_settings.name));
STRNCPY(scene->sequencer_colorspace_settings.name, colorspace_name);
BKE_image_format_init(&scene->r.im_format, true);
BKE_image_format_init(&scene->r.bake.im_format, true);
@ -2853,7 +2851,7 @@ SceneRenderView *BKE_scene_add_render_view(Scene *sce, const char *name)
}
SceneRenderView *srv = MEM_cnew<SceneRenderView>(__func__);
BLI_strncpy(srv->name, name, sizeof(srv->name));
STRNCPY(srv->name, name);
BLI_uniquename(&sce->r.views,
srv,
DATA_("RenderView"),
@ -3018,14 +3016,12 @@ void BKE_scene_disable_color_management(Scene *scene)
none_display_name = IMB_colormanagement_display_get_none_name();
BLI_strncpy(display_settings->display_device,
none_display_name,
sizeof(display_settings->display_device));
STRNCPY(display_settings->display_device, none_display_name);
view = IMB_colormanagement_view_get_default_name(display_settings->display_device);
if (view) {
BLI_strncpy(view_settings->view_transform, view, sizeof(view_settings->view_transform));
STRNCPY(view_settings->view_transform, view);
}
}
@ -3303,10 +3299,10 @@ void BKE_scene_multiview_view_filepath_get(const RenderData *rd,
srv = static_cast<SceneRenderView *>(
BLI_findstring(&rd->views, viewname, offsetof(SceneRenderView, name)));
if (srv) {
BLI_strncpy(suffix, srv->suffix, sizeof(suffix));
STRNCPY(suffix, srv->suffix);
}
else {
BLI_strncpy(suffix, viewname, sizeof(suffix));
STRNCPY(suffix, viewname);
}
BLI_strncpy(r_filepath, filepath, FILE_MAX);
@ -3543,7 +3539,7 @@ static Depsgraph **scene_ensure_depsgraph_p(Main *bmain, Scene *scene, ViewLayer
* we will ever enable debug messages for this depsgraph.
*/
char name[1024];
BLI_snprintf(name, sizeof(name), "%s :: %s", scene->id.name, view_layer->name);
SNPRINTF(name, "%s :: %s", scene->id.name, view_layer->name);
DEG_debug_name_set(*depsgraph_ptr, name);
/* These viewport depsgraphs communicate changes to the editors. */

View File

@ -65,7 +65,7 @@ ShaderFxData *BKE_shaderfx_new(int type)
ShaderFxData *fx = MEM_callocN(fxi->struct_size, fxi->struct_name);
/* NOTE: this name must be made unique later. */
BLI_strncpy(fx->name, DATA_(fxi->name), sizeof(fx->name));
STRNCPY(fx->name, DATA_(fxi->name));
fx->type = type;
fx->mode = eShaderFxMode_Realtime | eShaderFxMode_Render;

View File

@ -69,7 +69,7 @@ void ModifierSimulationCache::try_discover_bake(const StringRefNull meta_dir,
continue;
}
char modified_file_name[FILENAME_MAX];
BLI_strncpy(modified_file_name, dir_entry.relname, sizeof(modified_file_name));
STRNCPY(modified_file_name, dir_entry.relname);
BLI_str_replace_char(modified_file_name, '_', '.');
const SubFrame frame = std::stof(modified_file_name);

View File

@ -258,11 +258,11 @@ bSound *BKE_sound_new_file(Main *bmain, const char *filepath)
const char *blendfile_path = BKE_main_blendfile_path(bmain);
char str[FILE_MAX];
BLI_strncpy(str, filepath, sizeof(str));
STRNCPY(str, filepath);
BLI_path_abs(str, blendfile_path);
sound = BKE_libblock_alloc(bmain, ID_SO, BLI_path_basename(filepath), 0);
BLI_strncpy(sound->filepath, filepath, FILE_MAX);
STRNCPY(sound->filepath, filepath);
/* sound->type = SOUND_TYPE_FILE; */ /* XXX unused currently */
/* Extract sound specs for bSound */
@ -286,12 +286,12 @@ bSound *BKE_sound_new_file_exists_ex(Main *bmain, const char *filepath, bool *r_
bSound *sound;
char str[FILE_MAX], strtest[FILE_MAX];
BLI_strncpy(str, filepath, sizeof(str));
STRNCPY(str, filepath);
BLI_path_abs(str, BKE_main_blendfile_path(bmain));
/* first search an identical filepath */
for (sound = bmain->sounds.first; sound; sound = sound->id.next) {
BLI_strncpy(strtest, sound->filepath, sizeof(sound->filepath));
STRNCPY(strtest, sound->filepath);
BLI_path_abs(strtest, ID_BLEND_PATH(bmain, &sound->id));
if (BLI_path_cmp(strtest, str) == 0) {
@ -551,7 +551,7 @@ static void sound_load_audio(Main *bmain, bSound *sound, bool free_waveform)
PackedFile *pf = sound->packedfile;
/* don't modify soundact->sound->filepath, only change a copy */
BLI_strncpy(fullpath, sound->filepath, sizeof(fullpath));
STRNCPY(fullpath, sound->filepath);
BLI_path_abs(fullpath, ID_BLEND_PATH(bmain, &sound->id));
/* but we need a packed file then */
@ -1258,7 +1258,7 @@ bool BKE_sound_stream_info_get(struct Main *main,
AUD_StreamInfo *stream_infos;
int stream_count;
BLI_strncpy(str, filepath, sizeof(str));
STRNCPY(str, filepath);
BLI_path_abs(str, blendfile_path);
sound = AUD_Sound_file(str);

View File

@ -1407,7 +1407,7 @@ void BKE_studiolight_init(void)
StudioLight *sl = studiolight_create(
STUDIOLIGHT_INTERNAL | STUDIOLIGHT_SPHERICAL_HARMONICS_COEFFICIENTS_CALCULATED |
STUDIOLIGHT_TYPE_STUDIO | STUDIOLIGHT_SPECULAR_HIGHLIGHT_PASS);
BLI_strncpy(sl->name, "Default", FILE_MAXFILE);
STRNCPY(sl->name, "Default");
BLI_addtail(&studiolights, sl);

View File

@ -428,7 +428,7 @@ bool BKE_text_reload(Text *text)
return false;
}
BLI_strncpy(filepath_abs, text->filepath, FILE_MAX);
STRNCPY(filepath_abs, text->filepath);
BLI_path_abs(filepath_abs, ID_BLEND_PATH_FROM_GLOBAL(&text->id));
buffer = BLI_file_read_text_as_mem(filepath_abs, 0, &buffer_len);
@ -465,7 +465,7 @@ Text *BKE_text_load_ex(Main *bmain,
char filepath_abs[FILE_MAX];
BLI_stat_t st;
BLI_strncpy(filepath_abs, filepath, FILE_MAX);
STRNCPY(filepath_abs, filepath);
BLI_path_abs(filepath_abs, relbase);
buffer = BLI_file_read_text_as_mem(filepath_abs, 0, &buffer_len);
@ -537,7 +537,7 @@ int BKE_text_file_modified_check(Text *text)
return 0;
}
BLI_strncpy(filepath, text->filepath, FILE_MAX);
STRNCPY(filepath, text->filepath);
BLI_path_abs(filepath, ID_BLEND_PATH_FROM_GLOBAL(&text->id));
if (!BLI_exists(filepath)) {
@ -571,7 +571,7 @@ void BKE_text_file_modified_ignore(Text *text)
return;
}
BLI_strncpy(filepath, text->filepath, FILE_MAX);
STRNCPY(filepath, text->filepath);
BLI_path_abs(filepath, ID_BLEND_PATH_FROM_GLOBAL(&text->id));
if (!BLI_exists(filepath)) {

View File

@ -1902,12 +1902,12 @@ MovieTrackingObject *BKE_tracking_object_add(MovieTracking *tracking, const char
if (tracking->tot_object == 0) {
/* first object is always camera */
BLI_strncpy(tracking_object->name, "Camera", sizeof(tracking_object->name));
STRNCPY(tracking_object->name, "Camera");
tracking_object->flag |= TRACKING_OBJECT_CAMERA;
}
else {
BLI_strncpy(tracking_object->name, name, sizeof(tracking_object->name));
STRNCPY(tracking_object->name, name);
}
BLI_addtail(&tracking->objects, tracking_object);
@ -3194,10 +3194,10 @@ static void tracking_dopesheet_channels_calc(MovieTracking *tracking)
channel->track = track;
if (reconstruction->flag & TRACKING_RECONSTRUCTED) {
BLI_snprintf(channel->name, sizeof(channel->name), "%s (%.4f)", track->name, track->error);
SNPRINTF(channel->name, "%s (%.4f)", track->name, track->error);
}
else {
BLI_strncpy(channel->name, track->name, sizeof(channel->name));
STRNCPY(channel->name, track->name);
}
tracking_dopesheet_channels_segments_calc(channel);
@ -3407,19 +3407,19 @@ MovieTrackingObject *BKE_tracking_find_object_for_plane_track(
void BKE_tracking_get_rna_path_for_track(const struct MovieTracking *tracking,
const struct MovieTrackingTrack *track,
char *rna_path,
size_t rna_path_len)
size_t rna_path_maxncpy)
{
MovieTrackingObject *tracking_object = BKE_tracking_find_object_for_track(tracking, track);
char track_name_esc[MAX_NAME * 2];
BLI_str_escape(track_name_esc, track->name, sizeof(track_name_esc));
if (tracking_object == nullptr) {
BLI_snprintf(rna_path, rna_path_len, "tracking.tracks[\"%s\"]", track_name_esc);
BLI_snprintf(rna_path, rna_path_maxncpy, "tracking.tracks[\"%s\"]", track_name_esc);
}
else {
char object_name_esc[MAX_NAME * 2];
BLI_str_escape(object_name_esc, tracking_object->name, sizeof(object_name_esc));
BLI_snprintf(rna_path,
rna_path_len,
rna_path_maxncpy,
"tracking.objects[\"%s\"].tracks[\"%s\"]",
object_name_esc,
track_name_esc);
@ -3429,36 +3429,36 @@ void BKE_tracking_get_rna_path_for_track(const struct MovieTracking *tracking,
void BKE_tracking_get_rna_path_prefix_for_track(const struct MovieTracking *tracking,
const struct MovieTrackingTrack *track,
char *rna_path,
size_t rna_path_len)
size_t rna_path_maxncpy)
{
MovieTrackingObject *tracking_object = BKE_tracking_find_object_for_track(tracking, track);
if (tracking_object == nullptr) {
BLI_strncpy(rna_path, "tracking.tracks", rna_path_len);
BLI_strncpy(rna_path, "tracking.tracks", rna_path_maxncpy);
}
else {
char object_name_esc[MAX_NAME * 2];
BLI_str_escape(object_name_esc, tracking_object->name, sizeof(object_name_esc));
BLI_snprintf(rna_path, rna_path_len, "tracking.objects[\"%s\"]", object_name_esc);
BLI_snprintf(rna_path, rna_path_maxncpy, "tracking.objects[\"%s\"]", object_name_esc);
}
}
void BKE_tracking_get_rna_path_for_plane_track(const struct MovieTracking *tracking,
const struct MovieTrackingPlaneTrack *plane_track,
char *rna_path,
size_t rna_path_len)
size_t rna_path_maxncpy)
{
MovieTrackingObject *tracking_object = BKE_tracking_find_object_for_plane_track(tracking,
plane_track);
char track_name_esc[MAX_NAME * 2];
BLI_str_escape(track_name_esc, plane_track->name, sizeof(track_name_esc));
if (tracking_object == nullptr) {
BLI_snprintf(rna_path, rna_path_len, "tracking.plane_tracks[\"%s\"]", track_name_esc);
BLI_snprintf(rna_path, rna_path_maxncpy, "tracking.plane_tracks[\"%s\"]", track_name_esc);
}
else {
char object_name_esc[MAX_NAME * 2];
BLI_str_escape(object_name_esc, tracking_object->name, sizeof(object_name_esc));
BLI_snprintf(rna_path,
rna_path_len,
rna_path_maxncpy,
"tracking.objects[\"%s\"].plane_tracks[\"%s\"]",
object_name_esc,
track_name_esc);
@ -3469,16 +3469,17 @@ void BKE_tracking_get_rna_path_prefix_for_plane_track(
const struct MovieTracking *tracking,
const struct MovieTrackingPlaneTrack *plane_track,
char *rna_path,
size_t rna_path_len)
size_t rna_path_maxncpy)
{
MovieTrackingObject *tracking_object = BKE_tracking_find_object_for_plane_track(tracking,
plane_track);
if (tracking_object == nullptr) {
BLI_strncpy(rna_path, "tracking.plane_tracks", rna_path_len);
BLI_strncpy(rna_path, "tracking.plane_tracks", rna_path_maxncpy);
}
else {
char object_name_esc[MAX_NAME * 2];
BLI_str_escape(object_name_esc, tracking_object->name, sizeof(object_name_esc));
BLI_snprintf(rna_path, rna_path_len, "tracking.objects[\"%s\"].plane_tracks", object_name_esc);
BLI_snprintf(
rna_path, rna_path_maxncpy, "tracking.objects[\"%s\"].plane_tracks", object_name_esc);
}
}

View File

@ -334,7 +334,7 @@ MovieReconstructContext *BKE_tracking_reconstruction_context_new(
const int num_tracks = BLI_listbase_count(&tracking_object->tracks);
int sfra = INT_MAX, efra = INT_MIN;
BLI_strncpy(context->object_name, tracking_object->name, sizeof(context->object_name));
STRNCPY(context->object_name, tracking_object->name);
context->motion_flag = tracking->settings.motion_flag;
context->select_keyframes = (tracking->settings.reconstruction_flag &
@ -393,7 +393,7 @@ void BKE_tracking_reconstruction_report_error_message(MovieReconstructContext *c
/* Only keep initial error message, the rest are inducted ones. */
return;
}
BLI_strncpy(context->error_message, error_message, sizeof(context->error_message));
STRNCPY(context->error_message, error_message);
}
const char *BKE_tracking_reconstruction_error_message_get(const MovieReconstructContext *context)

View File

@ -52,7 +52,7 @@ TracksMap *tracks_map_new(const char *object_name, int num_tracks)
{
TracksMap *map = MEM_cnew<TracksMap>("TrackingsMap");
BLI_strncpy(map->object_name, object_name, sizeof(map->object_name));
STRNCPY(map->object_name, object_name);
map->num_tracks = num_tracks;

View File

@ -119,7 +119,7 @@ static void undosys_id_ref_store(void * /*user_data*/, UndoRefID *id_ref)
{
BLI_assert(id_ref->name[0] == '\0');
if (id_ref->ptr) {
BLI_strncpy(id_ref->name, id_ref->ptr->name, sizeof(id_ref->name));
STRNCPY(id_ref->name, id_ref->ptr->name);
/* Not needed, just prevents stale data access. */
id_ref->ptr = nullptr;
}
@ -456,7 +456,7 @@ UndoStep *BKE_undosys_step_push_init_with_type(UndoStack *ustack,
UndoStep *us = static_cast<UndoStep *>(MEM_callocN(ut->step_size, __func__));
if (name != nullptr) {
BLI_strncpy(us->name, name, sizeof(us->name));
STRNCPY(us->name, name);
}
us->type = ut;
ustack->step_init = us;
@ -541,7 +541,7 @@ eUndoPushReturn BKE_undosys_step_push_with_type(UndoStack *ustack,
static_cast<UndoStep *>(MEM_callocN(ut->step_size, __func__));
ustack->step_init = nullptr;
if (us->name[0] == '\0') {
BLI_strncpy(us->name, name, sizeof(us->name));
STRNCPY(us->name, name);
}
us->type = ut;
/* True by default, code needs to explicitly set it to false if necessary. */

View File

@ -1112,9 +1112,7 @@ bool BKE_unit_replace_string(
/* Apply the default unit on the whole expression, this allows to handle nasty cases like
* '2+2in'. */
if (BLI_snprintf(str_tmp, sizeof(str_tmp), "(%s)*%.9g", str, default_unit->scalar) <
sizeof(str_tmp))
{
if (SNPRINTF(str_tmp, "(%s)*%.9g", str, default_unit->scalar) < sizeof(str_tmp)) {
strncpy(str, str_tmp, str_maxncpy);
}
else {

View File

@ -66,7 +66,7 @@ static void vfont_init_data(ID *id)
if (vfd) {
vfont->data = vfd;
BLI_strncpy(vfont->filepath, FO_BUILTIN_NAME, sizeof(vfont->filepath));
STRNCPY(vfont->filepath, FO_BUILTIN_NAME);
}
/* Free the packed file */
@ -321,7 +321,7 @@ VFont *BKE_vfont_load(Main *bmain, const char *filepath)
bool is_builtin;
if (STREQ(filepath, FO_BUILTIN_NAME)) {
BLI_strncpy(filename, filepath, sizeof(filename));
STRNCPY(filename, filepath);
pf = get_builtin_packedfile();
is_builtin = true;
@ -341,7 +341,7 @@ VFont *BKE_vfont_load(Main *bmain, const char *filepath)
/* If there's a font name, use it for the ID name. */
vfont = BKE_libblock_alloc(bmain, ID_VF, vfd->name[0] ? vfd->name : filename, 0);
vfont->data = vfd;
BLI_strncpy(vfont->filepath, filepath, sizeof(vfont->filepath));
STRNCPY(vfont->filepath, filepath);
/* if auto-pack is on store the packed-file in de font structure */
if (!is_builtin && (G.fileflags & G_FILE_AUTOPACK)) {
@ -368,12 +368,12 @@ VFont *BKE_vfont_load_exists_ex(struct Main *bmain, const char *filepath, bool *
VFont *vfont;
char str[FILE_MAX], strtest[FILE_MAX];
BLI_strncpy(str, filepath, sizeof(str));
STRNCPY(str, filepath);
BLI_path_abs(str, BKE_main_blendfile_path(bmain));
/* first search an identical filepath */
for (vfont = bmain->fonts.first; vfont; vfont = vfont->id.next) {
BLI_strncpy(strtest, vfont->filepath, sizeof(vfont->filepath));
STRNCPY(strtest, vfont->filepath);
BLI_path_abs(strtest, ID_BLEND_PATH(bmain, &vfont->id));
if (BLI_path_cmp(strtest, str) == 0) {

View File

@ -321,7 +321,7 @@ VFontData *BKE_vfontdata_from_freetypefont(PackedFile *pf)
/* Get the name. */
if (face->family_name) {
BLI_snprintf(vfd->name, sizeof(vfd->name), "%s %s", face->family_name, face->style_name);
SNPRINTF(vfd->name, "%s %s", face->family_name, face->style_name);
BLI_str_utf8_invalid_strip(vfd->name, strlen(vfd->name));
}

View File

@ -515,7 +515,7 @@ static void volume_init_data(ID *id)
BKE_volume_init_grids(volume);
BLI_strncpy(volume->velocity_grid, "velocity", sizeof(volume->velocity_grid));
STRNCPY(volume->velocity_grid, "velocity");
}
static void volume_copy_data(Main * /*bmain*/, ID *id_dst, const ID *id_src, const int /*flag*/)
@ -793,7 +793,7 @@ bool BKE_volume_set_velocity_grid_by_name(Volume *volume, const char *base_name)
const StringRefNull ref_base_name = base_name;
if (BKE_volume_grid_find_for_read(volume, base_name)) {
BLI_strncpy(volume->velocity_grid, base_name, sizeof(volume->velocity_grid));
STRNCPY(volume->velocity_grid, base_name);
volume->runtime.velocity_x_grid[0] = '\0';
volume->runtime.velocity_y_grid[0] = '\0';
volume->runtime.velocity_z_grid[0] = '\0';
@ -818,16 +818,10 @@ bool BKE_volume_set_velocity_grid_by_name(Volume *volume, const char *base_name)
}
/* Save the base name as well. */
BLI_strncpy(volume->velocity_grid, base_name, sizeof(volume->velocity_grid));
BLI_strncpy(volume->runtime.velocity_x_grid,
(ref_base_name + postfix[0]).c_str(),
sizeof(volume->runtime.velocity_x_grid));
BLI_strncpy(volume->runtime.velocity_y_grid,
(ref_base_name + postfix[1]).c_str(),
sizeof(volume->runtime.velocity_y_grid));
BLI_strncpy(volume->runtime.velocity_z_grid,
(ref_base_name + postfix[2]).c_str(),
sizeof(volume->runtime.velocity_z_grid));
STRNCPY(volume->velocity_grid, base_name);
STRNCPY(volume->runtime.velocity_x_grid, (ref_base_name + postfix[0]).c_str());
STRNCPY(volume->runtime.velocity_y_grid, (ref_base_name + postfix[1]).c_str());
STRNCPY(volume->runtime.velocity_z_grid, (ref_base_name + postfix[2]).c_str());
return true;
}

View File

@ -224,7 +224,7 @@ static void workspace_layout_name_set(WorkSpace *workspace,
WorkSpaceLayout *layout,
const char *new_name)
{
BLI_strncpy(layout->name, new_name, sizeof(layout->name));
STRNCPY(layout->name, new_name);
BLI_uniquename(&workspace->layouts,
layout,
"Layout",

View File

@ -535,7 +535,7 @@ static const AVCodec *get_av1_encoder(
}
/* Set gop_size as rav1e's "--keyint". */
char buffer[64];
BLI_snprintf(buffer, sizeof(buffer), "keyint=%d", context->ffmpeg_gop_size);
SNPRINTF(buffer, "keyint=%d", context->ffmpeg_gop_size);
av_dict_set(opts, "rav1e-params", buffer, 0);
}
else if (STREQ(codec->name, "libsvtav1")) {
@ -1073,7 +1073,7 @@ static void ffmpeg_dict_set_int(AVDictionary **dict, const char *key, int value)
{
char buffer[32];
BLI_snprintf(buffer, sizeof(buffer), "%d", value);
SNPRINTF(buffer, "%d", value);
av_dict_set(dict, key, buffer, 0);
}
@ -1391,7 +1391,7 @@ static void ffmpeg_filepath_get(FFMpegContext *context,
if ((rd->ffcodecdata.flags & FFMPEG_AUTOSPLIT_OUTPUT) != 0) {
if (context) {
BLI_snprintf(autosplit, sizeof(autosplit), "_%03d", context->ffmpeg_autosplit_count);
SNPRINTF(autosplit, "_%03d", context->ffmpeg_autosplit_count);
}
}

View File

@ -17,7 +17,8 @@
#include "BLI_compiler_attrs.h"
#include "BLI_utildefines.h"
#if defined(_MSC_VER) || defined(__APPLE__) || defined(__HAIKU__) || defined(__NetBSD__)
#if defined(_MSC_VER) || defined(__APPLE__) || defined(__HAIKU__) || defined(__NetBSD__) || \
defined(__OpenBSD__)
typedef int64_t off64_t;
#endif

View File

@ -68,11 +68,11 @@ char *BLI_strdupcat(const char *__restrict str1,
*
* \param dst: Destination for copy
* \param src: Source string to copy
* \param maxncpy: Maximum number of characters to copy (generally
* \param dst_maxncpy: Maximum number of characters to copy (generally
* the size of dst)
* \retval Returns dst
*/
char *BLI_strncpy(char *__restrict dst, const char *__restrict src, size_t maxncpy)
char *BLI_strncpy(char *__restrict dst, const char *__restrict src, size_t dst_maxncpy)
ATTR_NONNULL(1, 2);
/**
@ -82,13 +82,13 @@ char *BLI_strncpy(char *__restrict dst, const char *__restrict src, size_t maxnc
* \param dst: Destination for copy
* \param src: Source string to copy
* \param pad: the char to use for padding
* \param maxncpy: Maximum number of characters to copy (generally the size of dst)
* \param dst_maxncpy: Maximum number of characters to copy (generally the size of dst)
* \retval Returns dst
*/
char *BLI_strncpy_ensure_pad(char *__restrict dst,
const char *__restrict src,
char pad,
size_t maxncpy) ATTR_NONNULL(1, 2);
size_t dst_maxncpy) ATTR_NONNULL(1, 2);
/**
* Like strncpy but ensures dst is always
@ -99,18 +99,18 @@ char *BLI_strncpy_ensure_pad(char *__restrict dst,
*
* \param dst: Destination for copy
* \param src: Source string to copy
* \param maxncpy: Maximum number of characters to copy (generally
* \param dst_maxncpy: Maximum number of characters to copy (generally
* the size of dst)
* \retval The number of bytes copied (The only difference from BLI_strncpy).
*/
size_t BLI_strncpy_rlen(char *__restrict dst,
const char *__restrict src,
size_t maxncpy) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1, 2);
size_t dst_maxncpy) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1, 2);
size_t BLI_strcpy_rlen(char *__restrict dst, const char *__restrict src) ATTR_WARN_UNUSED_RESULT
ATTR_NONNULL(1, 2);
char *BLI_strncat(char *__restrict dst, const char *__restrict src, size_t maxncpy)
char *BLI_strncat(char *__restrict dst, const char *__restrict src, size_t dst_maxncpy)
ATTR_NONNULL(1, 2);
/**
@ -194,26 +194,28 @@ bool BLI_str_replace_table_exact(char *string,
/**
* Portable replacement for #snprintf
*/
size_t BLI_snprintf(char *__restrict dst, size_t maxncpy, const char *__restrict format, ...)
size_t BLI_snprintf(char *__restrict dst, size_t dst_maxncpy, const char *__restrict format, ...)
ATTR_NONNULL(1, 3) ATTR_PRINTF_FORMAT(3, 4);
/**
* A version of #BLI_snprintf that returns `strlen(dst)`
*/
size_t BLI_snprintf_rlen(char *__restrict dst, size_t maxncpy, const char *__restrict format, ...)
ATTR_NONNULL(1, 3) ATTR_PRINTF_FORMAT(3, 4);
size_t BLI_snprintf_rlen(char *__restrict dst,
size_t dst_maxncpy,
const char *__restrict format,
...) ATTR_NONNULL(1, 3) ATTR_PRINTF_FORMAT(3, 4);
/**
* Portable replacement for `vsnprintf`.
*/
size_t BLI_vsnprintf(char *__restrict buffer,
size_t maxncpy,
size_t BLI_vsnprintf(char *__restrict dst,
size_t dst_maxncpy,
const char *__restrict format,
va_list arg) ATTR_PRINTF_FORMAT(3, 0);
/**
* A version of #BLI_vsnprintf that returns `strlen(buffer)`
* A version of #BLI_vsnprintf that returns `strlen(dst)`
*/
size_t BLI_vsnprintf_rlen(char *__restrict buffer,
size_t maxncpy,
size_t BLI_vsnprintf_rlen(char *__restrict dst,
size_t dst_maxncpy,
const char *__restrict format,
va_list arg) ATTR_PRINTF_FORMAT(3, 0);
@ -545,6 +547,8 @@ int BLI_string_find_split_words(const char *str,
#define SNPRINTF(dst, format, ...) BLI_snprintf(dst, ARRAY_SIZE(dst), format, __VA_ARGS__)
#define SNPRINTF_RLEN(dst, format, ...) \
BLI_snprintf_rlen(dst, ARRAY_SIZE(dst), format, __VA_ARGS__)
#define VSNPRINTF(dst, format, args) BLI_vsnprintf(dst, ARRAY_SIZE(dst), format, args)
#define VSNPRINTF_RLEN(dst, format, args) BLI_vsnprintf_rlen(dst, ARRAY_SIZE(dst), format, args)
#define STR_CONCAT(dst, len, suffix) \
len += BLI_strncpy_rlen(dst + len, suffix, ARRAY_SIZE(dst) - len)
#define STR_CONCATF(dst, len, format, ...) \

View File

@ -57,7 +57,7 @@ typedef uint64_t u_int64_t;
#ifndef __cplusplus
/* The <uchar.h> standard header is missing on some systems. */
# if defined(__APPLE__) || defined(__NetBSD__)
# if defined(__APPLE__) || defined(__NetBSD__) || defined(__OpenBSD__)
typedef unsigned int char32_t;
# else
# include <uchar.h>

View File

@ -151,7 +151,7 @@ static void bli_builddir(struct BuildDirCtx *dir_ctx, const char *dirname)
if (!has_parent) {
char pardir[FILE_MAXDIR];
BLI_strncpy(pardir, dirname, sizeof(pardir));
STRNCPY(pardir, dirname);
if (BLI_path_parent_dir(pardir) && (BLI_access(pardir, R_OK) == 0)) {
struct dirlink *const dlink = (struct dirlink *)malloc(sizeof(struct dirlink));
if (dlink != NULL) {

View File

@ -645,7 +645,7 @@ void BLI_path_rel(char *path, const char *basename)
}
}
#else
BLI_strncpy(temp, basename, FILE_MAX);
STRNCPY(temp, basename);
#endif
BLI_str_replace_char(temp + BLI_path_unc_prefix_len(temp), '\\', '/');
@ -887,8 +887,7 @@ bool BLI_path_frame(char *path, size_t path_maxncpy, int frame, int digits)
if (stringframe_chars(path, &ch_sta, &ch_end)) { /* Warning: `ch_end` is the last # +1. */
char tmp[FILE_MAX];
BLI_snprintf(
tmp, sizeof(tmp), "%.*s%.*d%s", ch_sta, path, ch_end - ch_sta, frame, path + ch_end);
SNPRINTF(tmp, "%.*s%.*d%s", ch_sta, path, ch_end - ch_sta, frame, path + ch_end);
BLI_strncpy(path, tmp, path_maxncpy);
return true;
}
@ -907,16 +906,15 @@ bool BLI_path_frame_range(char *path, int sta, int end, int digits)
if (stringframe_chars(path, &ch_sta, &ch_end)) { /* Warning: `ch_end` is the last # +1. */
char tmp[FILE_MAX];
BLI_snprintf(tmp,
sizeof(tmp),
"%.*s%.*d-%.*d%s",
ch_sta,
path,
ch_end - ch_sta,
sta,
ch_end - ch_sta,
end,
path + ch_end);
SNPRINTF(tmp,
"%.*s%.*d-%.*d%s",
ch_sta,
path,
ch_end - ch_sta,
sta,
ch_end - ch_sta,
end,
path + ch_end);
BLI_strncpy(path, tmp, FILE_MAX);
return true;
}
@ -1054,7 +1052,7 @@ bool BLI_path_abs(char *path, const char *basepath)
BLI_strncpy(tmp, path, FILE_MAX);
}
#else
BLI_strncpy(tmp, path, sizeof(tmp));
STRNCPY(tmp, path);
/* Check for loading a MS-Windows path on a POSIX system
* in this case, there is no use in trying `C:/` since it
@ -1086,7 +1084,7 @@ bool BLI_path_abs(char *path, const char *basepath)
* this isn't standard in any OS but is used in blender all over the place. */
if (wasrelative) {
const char *lslash;
BLI_strncpy(base, basepath, sizeof(base));
STRNCPY(base, basepath);
/* File component is ignored, so don't bother with the trailing slash. */
BLI_path_normalize(base);
@ -1152,7 +1150,7 @@ bool BLI_path_abs_from_cwd(char *path, const size_t path_maxncpy)
/* In case the full path to the blend isn't used. */
if (BLI_current_working_dir(cwd, sizeof(cwd))) {
char origpath[FILE_MAX];
BLI_strncpy(origpath, path, FILE_MAX);
STRNCPY(origpath, path);
BLI_path_join(path, path_maxncpy, cwd, origpath);
}
else {
@ -1245,7 +1243,7 @@ bool BLI_path_program_search(char *program_filepath,
path = temp + 1;
}
else {
BLI_strncpy(filepath_test, path, sizeof(filepath_test));
STRNCPY(filepath_test, path);
}
BLI_path_append(filepath_test, program_filepath_maxncpy, program_name);
@ -1391,7 +1389,7 @@ bool BLI_path_extension_check_glob(const char *path, const char *ext_fnmatch)
BLI_strncpy(pattern, ext_step, (len_ext > sizeof(pattern)) ? sizeof(pattern) : len_ext);
}
else {
len_ext = BLI_strncpy_rlen(pattern, ext_step, sizeof(pattern));
len_ext = STRNCPY_RLEN(pattern, ext_step);
}
if (fnmatch(pattern, path, FNM_CASEFOLD) == 0) {
@ -1811,7 +1809,7 @@ bool BLI_path_contains(const char *container_path, const char *containee_path)
/* Keep space for a trailing slash. If the path is truncated by this, the containee path is
* longer than #PATH_MAX and the result is ill-defined. */
BLI_strncpy(container_native, container_path, PATH_MAX - 1);
BLI_strncpy(containee_native, containee_path, PATH_MAX);
STRNCPY(containee_native, containee_path);
BLI_path_slash_native(container_native);
BLI_path_slash_native(containee_native);
@ -1916,8 +1914,8 @@ int BLI_path_cmp_normalized(const char *p1, const char *p2)
char norm_p1[FILE_MAX];
char norm_p2[FILE_MAX];
BLI_strncpy(norm_p1, p1, sizeof(norm_p1));
BLI_strncpy(norm_p2, p2, sizeof(norm_p2));
STRNCPY(norm_p1, p1);
STRNCPY(norm_p2, p2);
BLI_path_slash_native(norm_p1);
BLI_path_slash_native(norm_p2);

View File

@ -13,7 +13,7 @@
#include <sys/stat.h>
#if defined(__NetBSD__) || defined(__DragonFly__) || defined(__HAIKU__)
#if defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) || defined(__HAIKU__)
/* Other modern unix OS's should probably use this also. */
# include <sys/statvfs.h>
# define USE_STATFS_STATVFS

View File

@ -59,12 +59,12 @@ char *BLI_strdupcat(const char *__restrict str1, const char *__restrict str2)
return str;
}
char *BLI_strncpy(char *__restrict dst, const char *__restrict src, const size_t maxncpy)
char *BLI_strncpy(char *__restrict dst, const char *__restrict src, const size_t dst_maxncpy)
{
BLI_string_debug_size(dst, maxncpy);
BLI_string_debug_size(dst, dst_maxncpy);
BLI_assert(maxncpy != 0);
size_t srclen = BLI_strnlen(src, maxncpy - 1);
BLI_assert(dst_maxncpy != 0);
size_t srclen = BLI_strnlen(src, dst_maxncpy - 1);
memcpy(dst, src, srclen);
dst[srclen] = '\0';
@ -74,10 +74,10 @@ char *BLI_strncpy(char *__restrict dst, const char *__restrict src, const size_t
char *BLI_strncpy_ensure_pad(char *__restrict dst,
const char *__restrict src,
const char pad,
size_t maxncpy)
size_t dst_maxncpy)
{
BLI_string_debug_size(dst, maxncpy);
BLI_assert(maxncpy != 0);
BLI_string_debug_size(dst, dst_maxncpy);
BLI_assert(dst_maxncpy != 0);
if (src[0] == '\0') {
dst[0] = '\0';
@ -89,12 +89,12 @@ char *BLI_strncpy_ensure_pad(char *__restrict dst,
if (src[idx] != pad) {
dst[idx++] = pad;
maxncpy--;
dst_maxncpy--;
}
maxncpy--; /* trailing '\0' */
dst_maxncpy--; /* trailing '\0' */
srclen = BLI_strnlen(src, maxncpy);
if ((src[srclen - 1] != pad) && (srclen == maxncpy)) {
srclen = BLI_strnlen(src, dst_maxncpy);
if ((src[srclen - 1] != pad) && (srclen == dst_maxncpy)) {
srclen--;
}
@ -110,12 +110,12 @@ char *BLI_strncpy_ensure_pad(char *__restrict dst,
return dst;
}
size_t BLI_strncpy_rlen(char *__restrict dst, const char *__restrict src, const size_t maxncpy)
size_t BLI_strncpy_rlen(char *__restrict dst, const char *__restrict src, const size_t dst_maxncpy)
{
BLI_string_debug_size(dst, maxncpy);
BLI_string_debug_size(dst, dst_maxncpy);
size_t srclen = BLI_strnlen(src, maxncpy - 1);
BLI_assert(maxncpy != 0);
size_t srclen = BLI_strnlen(src, dst_maxncpy - 1);
BLI_assert(dst_maxncpy != 0);
memcpy(dst, src, srclen);
dst[srclen] = '\0';
@ -133,13 +133,13 @@ size_t BLI_strcpy_rlen(char *__restrict dst, const char *__restrict src)
/** \name String Append
* \{ */
char *BLI_strncat(char *__restrict dst, const char *__restrict src, const size_t maxncpy)
char *BLI_strncat(char *__restrict dst, const char *__restrict src, const size_t dst_maxncpy)
{
BLI_string_debug_size(dst, maxncpy);
BLI_string_debug_size(dst, dst_maxncpy);
size_t len = BLI_strnlen(dst, maxncpy);
if (len < maxncpy) {
BLI_strncpy(dst + len, src, maxncpy - len);
size_t len = BLI_strnlen(dst, dst_maxncpy);
if (len < dst_maxncpy) {
BLI_strncpy(dst + len, src, dst_maxncpy - len);
}
return dst;
}
@ -150,80 +150,83 @@ char *BLI_strncat(char *__restrict dst, const char *__restrict src, const size_t
/** \name String Printing
* \{ */
size_t BLI_vsnprintf(char *__restrict buffer,
size_t maxncpy,
size_t BLI_vsnprintf(char *__restrict dst,
size_t dst_maxncpy,
const char *__restrict format,
va_list arg)
{
BLI_string_debug_size(buffer, maxncpy);
BLI_string_debug_size(dst, dst_maxncpy);
size_t n;
BLI_assert(buffer != NULL);
BLI_assert(maxncpy > 0);
BLI_assert(dst != NULL);
BLI_assert(dst_maxncpy > 0);
BLI_assert(format != NULL);
n = (size_t)vsnprintf(buffer, maxncpy, format, arg);
n = (size_t)vsnprintf(dst, dst_maxncpy, format, arg);
if (n != -1 && n < maxncpy) {
buffer[n] = '\0';
if (n != -1 && n < dst_maxncpy) {
dst[n] = '\0';
}
else {
buffer[maxncpy - 1] = '\0';
dst[dst_maxncpy - 1] = '\0';
}
return n;
}
size_t BLI_vsnprintf_rlen(char *__restrict buffer,
size_t maxncpy,
size_t BLI_vsnprintf_rlen(char *__restrict dst,
size_t dst_maxncpy,
const char *__restrict format,
va_list arg)
{
BLI_string_debug_size(buffer, maxncpy);
BLI_string_debug_size(dst, dst_maxncpy);
size_t n;
BLI_assert(buffer != NULL);
BLI_assert(maxncpy > 0);
BLI_assert(dst != NULL);
BLI_assert(dst_maxncpy > 0);
BLI_assert(format != NULL);
n = (size_t)vsnprintf(buffer, maxncpy, format, arg);
n = (size_t)vsnprintf(dst, dst_maxncpy, format, arg);
if (n != -1 && n < maxncpy) {
if (n != -1 && n < dst_maxncpy) {
/* pass */
}
else {
n = maxncpy - 1;
n = dst_maxncpy - 1;
}
buffer[n] = '\0';
dst[n] = '\0';
return n;
}
size_t BLI_snprintf(char *__restrict dst, size_t maxncpy, const char *__restrict format, ...)
size_t BLI_snprintf(char *__restrict dst, size_t dst_maxncpy, const char *__restrict format, ...)
{
BLI_string_debug_size(dst, maxncpy);
BLI_string_debug_size(dst, dst_maxncpy);
size_t n;
va_list arg;
va_start(arg, format);
n = BLI_vsnprintf(dst, maxncpy, format, arg);
n = BLI_vsnprintf(dst, dst_maxncpy, format, arg);
va_end(arg);
return n;
}
size_t BLI_snprintf_rlen(char *__restrict dst, size_t maxncpy, const char *__restrict format, ...)
size_t BLI_snprintf_rlen(char *__restrict dst,
size_t dst_maxncpy,
const char *__restrict format,
...)
{
BLI_string_debug_size(dst, maxncpy);
BLI_string_debug_size(dst, dst_maxncpy);
size_t n;
va_list arg;
va_start(arg, format);
n = BLI_vsnprintf_rlen(dst, maxncpy, format, arg);
n = BLI_vsnprintf_rlen(dst, dst_maxncpy, format, arg);
va_end(arg);
return n;
@ -445,9 +448,9 @@ char *BLI_str_quoted_substrN(const char *__restrict str, const char *__restrict
bool BLI_str_quoted_substr(const char *__restrict str,
const char *__restrict prefix,
char *result,
size_t result_maxlen)
size_t result_maxncpy)
{
BLI_string_debug_size(result, result_maxlen);
BLI_string_debug_size(result, result_maxncpy);
int start_match_ofs, end_match_ofs;
if (!BLI_str_quoted_substr_range(str, prefix, &start_match_ofs, &end_match_ofs)) {
@ -455,7 +458,7 @@ bool BLI_str_quoted_substr(const char *__restrict str,
}
const size_t escaped_len = (size_t)(end_match_ofs - start_match_ofs);
bool is_complete;
BLI_str_unescape_ex(result, str + start_match_ofs, escaped_len, result_maxlen, &is_complete);
BLI_str_unescape_ex(result, str + start_match_ofs, escaped_len, result_maxncpy, &is_complete);
if (is_complete == false) {
*result = '\0';
}
@ -1138,20 +1141,24 @@ static size_t BLI_str_format_int_grouped_ex(char *src, char *dst, int num_len)
size_t BLI_str_format_int_grouped(char dst[BLI_STR_FORMAT_INT32_GROUPED_SIZE], int num)
{
BLI_string_debug_size(dst, BLI_STR_FORMAT_INT32_GROUPED_SIZE);
const size_t dst_maxncpy = BLI_STR_FORMAT_INT32_GROUPED_SIZE;
BLI_string_debug_size(dst, dst_maxncpy);
UNUSED_VARS_NDEBUG(dst_maxncpy);
char src[BLI_STR_FORMAT_INT32_GROUPED_SIZE];
const int num_len = BLI_snprintf(src, sizeof(src), "%d", num);
const int num_len = SNPRINTF(src, "%d", num);
return BLI_str_format_int_grouped_ex(src, dst, num_len);
}
size_t BLI_str_format_uint64_grouped(char dst[BLI_STR_FORMAT_UINT64_GROUPED_SIZE], uint64_t num)
{
BLI_string_debug_size(dst, BLI_STR_FORMAT_UINT64_GROUPED_SIZE);
const size_t dst_maxncpy = BLI_STR_FORMAT_UINT64_GROUPED_SIZE;
BLI_string_debug_size(dst, dst_maxncpy);
UNUSED_VARS_NDEBUG(dst_maxncpy);
char src[BLI_STR_FORMAT_UINT64_GROUPED_SIZE];
const int num_len = BLI_snprintf(src, sizeof(src), "%" PRIu64 "", num);
const int num_len = SNPRINTF(src, "%" PRIu64 "", num);
return BLI_str_format_int_grouped_ex(src, dst, num_len);
}
@ -1160,7 +1167,8 @@ void BLI_str_format_byte_unit(char dst[BLI_STR_FORMAT_INT64_BYTE_UNIT_SIZE],
long long int bytes,
const bool base_10)
{
BLI_string_debug_size(dst, BLI_STR_FORMAT_INT64_BYTE_UNIT_SIZE);
const size_t dst_maxncpy = BLI_STR_FORMAT_INT64_BYTE_UNIT_SIZE;
BLI_string_debug_size(dst, dst_maxncpy);
double bytes_converted = bytes;
int order = 0;
@ -1179,11 +1187,10 @@ void BLI_str_format_byte_unit(char dst[BLI_STR_FORMAT_INT64_BYTE_UNIT_SIZE],
decimals = MAX2(order - 1, 0);
/* Format value first, stripping away floating zeroes. */
const size_t dst_len = BLI_STR_FORMAT_INT64_BYTE_UNIT_SIZE;
size_t len = BLI_snprintf_rlen(dst, dst_len, "%.*f", decimals, bytes_converted);
size_t len = BLI_snprintf_rlen(dst, dst_maxncpy, "%.*f", decimals, bytes_converted);
len -= (size_t)BLI_str_rstrip_float_zero(dst, '\0');
dst[len++] = ' ';
BLI_strncpy(dst + len, base_10 ? units_base_10[order] : units_base_2[order], dst_len - len);
BLI_strncpy(dst + len, base_10 ? units_base_10[order] : units_base_2[order], dst_maxncpy - len);
}
void BLI_str_format_decimal_unit(char dst[BLI_STR_FORMAT_INT32_DECIMAL_UNIT_SIZE],
@ -1202,18 +1209,19 @@ void BLI_str_format_decimal_unit(char dst[BLI_STR_FORMAT_INT32_DECIMAL_UNIT_SIZE
order++;
}
const size_t dst_len = BLI_STR_FORMAT_INT32_DECIMAL_UNIT_SIZE;
const size_t dst_maxncpy = BLI_STR_FORMAT_INT32_DECIMAL_UNIT_SIZE;
int decimals = 0;
if ((order > 0) && fabsf(number_to_format_converted) < 100.0f) {
decimals = 1;
}
BLI_snprintf(dst, dst_len, "%.*f%s", decimals, number_to_format_converted, units[order]);
BLI_snprintf(dst, dst_maxncpy, "%.*f%s", decimals, number_to_format_converted, units[order]);
}
void BLI_str_format_integer_unit(char dst[BLI_STR_FORMAT_INT32_INTEGER_UNIT_SIZE],
const int number_to_format)
{
BLI_string_debug_size(dst, BLI_STR_FORMAT_INT32_INTEGER_UNIT_SIZE);
const size_t dst_maxncpy = BLI_STR_FORMAT_INT32_INTEGER_UNIT_SIZE;
BLI_string_debug_size(dst, dst_maxncpy);
float number_to_format_converted = number_to_format;
int order = 0;
@ -1233,9 +1241,8 @@ void BLI_str_format_integer_unit(char dst[BLI_STR_FORMAT_INT32_INTEGER_UNIT_SIZE
order++;
}
const size_t dst_len = BLI_STR_FORMAT_INT32_INTEGER_UNIT_SIZE;
BLI_snprintf(dst,
dst_len,
dst_maxncpy,
"%s%s%d%s",
number_to_format < 0 ? "-" : "",
add_dot ? "." : "",

View File

@ -269,7 +269,7 @@ bool BLI_uniquename_cb(UniquenameCheckCallback unique_check,
size_t len = BLI_string_split_name_number(name, delim, left, &number);
do {
/* add 1 to account for \0 */
const size_t numlen = BLI_snprintf(numstr, sizeof(numstr), "%c%03d", delim, ++number) + 1;
const size_t numlen = SNPRINTF(numstr, "%c%03d", delim, ++number) + 1;
/* highly unlikely the string only has enough room for the number
* but support anyway */

View File

@ -122,10 +122,10 @@ TEST(listbase, FindLinkFromStringOrPointer)
ListBase lb;
struct TestLink *link1 = (struct TestLink *)MEM_callocN(sizeof(TestLink), "link1");
BLI_strncpy(link1->name, link1_name, sizeof(link1->name));
STRNCPY(link1->name, link1_name);
link1->ptr = link1_ptr;
struct TestLink *link2 = (struct TestLink *)MEM_callocN(sizeof(TestLink), "link2");
BLI_strncpy(link2->name, link2_name, sizeof(link2->name));
STRNCPY(link2->name, link2_name);
link2->ptr = link2_ptr;
/* Empty list */

View File

@ -711,7 +711,7 @@ TEST(path_util, SplitDirfile)
{ \
char path[FILE_MAX]; \
char ext[FILE_MAX]; \
BLI_strncpy(path, (input_path), FILE_MAX); \
STRNCPY(path, (input_path)); \
BLI_path_frame_strip(path, ext, sizeof(ext)); \
EXPECT_STREQ(path, expect_path); \
EXPECT_STREQ(ext, expect_ext); \
@ -814,7 +814,7 @@ TEST(path_util, ExtensionCheck)
{ \
BLI_assert(maxlen <= FILE_MAX); \
char path[FILE_MAX]; \
BLI_strncpy(path, input_path, sizeof(path)); \
STRNCPY(path, input_path); \
const bool ret = BLI_path_extension_replace(path, maxlen, input_ext); \
if (expect_result) { \
EXPECT_TRUE(ret); \
@ -885,7 +885,7 @@ TEST(path_util, ExtensionReplace_Overflow)
{ \
BLI_assert(maxlen <= FILE_MAX); \
char path[FILE_MAX]; \
BLI_strncpy(path, input_path, sizeof(path)); \
STRNCPY(path, input_path); \
const bool ret = BLI_path_extension_ensure(path, maxlen, input_ext); \
if (expect_result) { \
EXPECT_TRUE(ret); \
@ -986,7 +986,7 @@ TEST(path_util, FrameCheckChars)
{ \
char path[FILE_MAX]; \
bool ret; \
BLI_strncpy(path, input_path, FILE_MAX); \
STRNCPY(path, input_path); \
ret = BLI_path_frame_range(path, sta, end, digits); \
if (expect_outpath == nullptr) { \
EXPECT_FALSE(ret); \
@ -1023,7 +1023,7 @@ TEST(path_util, FrameRange)
{ \
char path[FILE_MAX]; \
int out_frame = -1, out_numdigits = -1; \
BLI_strncpy(path, input_path, FILE_MAX); \
STRNCPY(path, input_path); \
const bool ret = BLI_path_frame_get(path, &out_frame, &out_numdigits); \
if (expect_pathisvalid) { \
EXPECT_TRUE(ret); \
@ -1136,7 +1136,7 @@ TEST(path_util, Suffix)
{ \
char path[FILE_MAX]; \
const char *ref_path_test = ref_path; \
BLI_strncpy(path, abs_path, sizeof(path)); \
STRNCPY(path, abs_path); \
if (SEP == '\\') { \
BLI_str_replace_char(path, '/', '\\'); \
ref_path_test = str_replace_char_strdup(ref_path_test, '/', '\\'); \

View File

@ -20,7 +20,8 @@ using std::string;
using std::vector;
/* -------------------------------------------------------------------- */
/* tests */
/** \name String Partition
* \{ */
/* BLI_str_partition */
TEST(string, StrPartition)
@ -321,6 +322,12 @@ TEST(string, StrPartitionExUtf8)
}
}
/** \} */
/* -------------------------------------------------------------------- */
/** \name String Format Integer (Grouped)
* \{ */
/* BLI_str_format_int_grouped */
TEST(string, StrFormatIntGrouped)
{
@ -381,6 +388,12 @@ TEST(string, StrFormatUint64Grouped)
EXPECT_EQ(sizeof(number_str), strlen(number_str) + 1);
}
/** \} */
/* -------------------------------------------------------------------- */
/** \name String Format Byte Units
* \{ */
/* BLI_str_format_byte_unit */
TEST(string, StrFormatByteUnits)
{
@ -448,6 +461,12 @@ TEST(string, StrFormatByteUnits)
EXPECT_EQ(sizeof(size_str), strlen(size_str) + 1);
}
/** \} */
/* -------------------------------------------------------------------- */
/** \name String Format Decimal Units
* \{ */
/* BLI_str_format_decimal_unit */
TEST(string, StrFormatDecimalUnits)
{
@ -640,6 +659,12 @@ TEST(string, StrFormatIntegerUnits)
EXPECT_STREQ("-2B", size_str);
}
/** \} */
/* -------------------------------------------------------------------- */
/** \name String Length (Clamped)
* \{ */
TEST(string, StringNLen)
{
EXPECT_EQ(0, BLI_strnlen("", 0));
@ -659,6 +684,12 @@ TEST(string, StringNLen)
EXPECT_EQ(47, BLI_strnlen("This string writes about an agent without name.", 100));
}
/** \} */
/* -------------------------------------------------------------------- */
/** \name String Find Split Words
* \{ */
struct WordInfo {
WordInfo() = default;
WordInfo(int start, int end) : start(start), end(end) {}
@ -778,6 +809,12 @@ TEST_F(StringFindSplitWords, LimitChars)
testStringFindSplitWords(words, 0, {{-1, -1}});
}
/** \} */
/* -------------------------------------------------------------------- */
/** \name String Search (Case Insensitive)
* \{ */
/* BLI_strncasestr */
TEST(string, StringStrncasestr)
{
@ -803,6 +840,12 @@ TEST(string, StringStrncasestr)
EXPECT_EQ(res, (void *)nullptr);
}
/** \} */
/* -------------------------------------------------------------------- */
/** \name String Maximum Word Count
* \{ */
/* BLI_string_max_possible_word_count */
TEST(string, StringMaxPossibleWordCount)
{
@ -813,6 +856,12 @@ TEST(string, StringMaxPossibleWordCount)
EXPECT_EQ(BLI_string_max_possible_word_count(10), 6);
}
/** \} */
/* -------------------------------------------------------------------- */
/** \name String is Decimal
* \{ */
/* BLI_string_is_decimal */
TEST(string, StrIsDecimal)
{
@ -832,6 +881,12 @@ TEST(string, StrIsDecimal)
EXPECT_TRUE(BLI_string_is_decimal("11342908713948713498745980171334059871345098713405981734"));
}
/** \} */
/* -------------------------------------------------------------------- */
/** \name String Natural Case Insensitive Comparison
* \{ */
/* BLI_strcasecmp_natural */
class StringCasecmpNatural : public testing::Test {
protected:
@ -876,6 +931,12 @@ class StringCasecmpNatural : public testing::Test {
}
};
/** \} */
/* -------------------------------------------------------------------- */
/** \name String Case Insensitive Comparison
* \{ */
TEST_F(StringCasecmpNatural, Empty)
{
const CompareWordsArray equal{
@ -1036,7 +1097,13 @@ TEST_F(StringCasecmpNatural, TextAndNumbers)
testReturnsMoreThanZeroForAll(positive);
}
/* BLI_str_escape, BLI_str_unescape */
/** \} */
/* -------------------------------------------------------------------- */
/** \name String Escape/Un-Escape
*
* #BLI_str_escape, #BLI_str_unescape.
* \{ */
class StringEscape : public testing::Test {
protected:
@ -1119,3 +1186,5 @@ TEST_F(StringEscape, Control)
testEscapeWords(escaped);
}
/** \} */

View File

@ -448,7 +448,7 @@ BlendFileData *BLO_read_from_memfile(Main *oldmain,
fd = blo_filedata_from_memfile(memfile, params, &bf_reports);
if (fd) {
fd->skip_flags = eBLOReadSkip(params->skip_flags);
BLI_strncpy(fd->relabase, filepath, sizeof(fd->relabase));
STRNCPY(fd->relabase, filepath);
/* separate libraries from old main */
blo_split_main(&old_mainlist, oldmain);

View File

@ -517,7 +517,7 @@ static Main *blo_find_main(FileData *fd, const char *filepath, const char *relab
Library *lib;
char filepath_abs[FILE_MAX];
BLI_strncpy(filepath_abs, filepath, sizeof(filepath_abs));
STRNCPY(filepath_abs, filepath);
BLI_path_abs(filepath_abs, relabase);
BLI_path_normalize(filepath_abs);
@ -550,8 +550,8 @@ static Main *blo_find_main(FileData *fd, const char *filepath, const char *relab
/* Matches direct_link_library(). */
id_us_ensure_real(&lib->id);
BLI_strncpy(lib->filepath, filepath, sizeof(lib->filepath));
BLI_strncpy(lib->filepath_abs, filepath_abs, sizeof(lib->filepath_abs));
STRNCPY(lib->filepath, filepath);
STRNCPY(lib->filepath_abs, filepath_abs);
m->curlib = lib;
@ -1185,7 +1185,7 @@ FileData *blo_filedata_from_file(const char *filepath, BlendFileReadReport *repo
FileData *fd = blo_filedata_from_file_open(filepath, reports);
if (fd != nullptr) {
/* needed for library_append and read_libraries */
BLI_strncpy(fd->relabase, filepath, sizeof(fd->relabase));
STRNCPY(fd->relabase, filepath);
return blo_decode_and_check(fd, reports->reports);
}
@ -2698,7 +2698,7 @@ static void direct_link_library(FileData *fd, Library *lib, Main *main)
}
/* Make sure we have full path in lib->filepath_abs */
BLI_strncpy(lib->filepath_abs, lib->filepath, sizeof(lib->filepath));
STRNCPY(lib->filepath_abs, lib->filepath);
BLI_path_abs(lib->filepath_abs, fd->relabase);
BLI_path_normalize(lib->filepath_abs);
@ -2733,7 +2733,7 @@ static void fix_relpaths_library(const char *basepath, Main *main)
* link into an unsaved blend file. See #27405.
* The remap relative option will make it relative again on save - campbell */
if (BLI_path_is_rel(lib->filepath)) {
BLI_strncpy(lib->filepath, lib->filepath_abs, sizeof(lib->filepath));
STRNCPY(lib->filepath, lib->filepath_abs);
}
}
}
@ -2743,7 +2743,7 @@ static void fix_relpaths_library(const char *basepath, Main *main)
* relative to the blend file since indirectly linked libraries will be
* relative to their direct linked library. */
if (BLI_path_is_rel(lib->filepath)) { /* if this is relative to begin with? */
BLI_strncpy(lib->filepath, lib->filepath_abs, sizeof(lib->filepath));
STRNCPY(lib->filepath, lib->filepath_abs);
BLI_path_rel(lib->filepath, basepath);
}
}
@ -3401,7 +3401,7 @@ static BHead *read_global(BlendFileData *bfd, FileData *fd, BHead *bhead)
bfd->main->minversionfile = fg->minversion;
bfd->main->minsubversionfile = fg->minsubversion;
bfd->main->build_commit_timestamp = fg->build_commit_timestamp;
BLI_strncpy(bfd->main->build_hash, fg->build_hash, sizeof(bfd->main->build_hash));
STRNCPY(bfd->main->build_hash, fg->build_hash);
bfd->fileflags = fg->fileflags;
bfd->globalf = fg->globalf;
@ -3423,7 +3423,7 @@ static BHead *read_global(BlendFileData *bfd, FileData *fd, BHead *bhead)
}
if (G.fileflags & G_FILE_RECOVER_READ) {
BLI_strncpy(fd->relabase, fg->filepath, sizeof(fd->relabase));
STRNCPY(fd->relabase, fg->filepath);
}
bfd->curscreen = fg->curscreen;
@ -3485,7 +3485,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
strftime(build_commit_datetime, sizeof(build_commit_datetime), "%Y-%m-%d %H:%M", tm);
}
else {
BLI_strncpy(build_commit_datetime, "unknown", sizeof(build_commit_datetime));
STRNCPY(build_commit_datetime, "unknown");
}
CLOG_INFO(&LOG, 0, "Read file %s", fd->relabase);
@ -4548,7 +4548,7 @@ static void library_link_end(Main *mainl, FileData **fd, const int flag)
/* make the lib path relative if required */
if (flag & FILE_RELPATH) {
/* use the full path, this could have been read by other library even */
BLI_strncpy(curlib->filepath, curlib->filepath_abs, sizeof(curlib->filepath));
STRNCPY(curlib->filepath, curlib->filepath_abs);
/* uses current .blend file as reference */
BLI_path_rel(curlib->filepath, BKE_main_blendfile_path_from_global());
@ -4828,7 +4828,7 @@ static FileData *read_library_file_data(FileData *basefd,
fd = blo_filedata_from_memory(pf->data, pf->size, basefd->reports);
/* Needed for library_append and read_libraries. */
BLI_strncpy(fd->relabase, mainptr->curlib->filepath_abs, sizeof(fd->relabase));
STRNCPY(fd->relabase, mainptr->curlib->filepath_abs);
}
else {
/* Read file on disk. */

View File

@ -565,7 +565,7 @@ static bNodeSocket *do_versions_node_group_add_socket_2_56_2(bNodeTree *ngroup,
// bNodeSocketType *stype = ntreeGetSocketType(type);
bNodeSocket *gsock = MEM_callocN(sizeof(bNodeSocket), "bNodeSocket");
BLI_strncpy(gsock->name, name, sizeof(gsock->name));
STRNCPY(gsock->name, name);
gsock->type = type;
gsock->next = gsock->prev = NULL;
@ -640,7 +640,7 @@ static bool seq_sound_proxy_update_cb(Sequence *seq, void *user_data)
#define SEQ_USE_PROXY_CUSTOM_FILE (1 << 21)
/* don't know, if anybody used that this way, but just in case, upgrade to new way... */
if ((seq->flag & SEQ_USE_PROXY_CUSTOM_FILE) && !(seq->flag & SEQ_USE_PROXY_CUSTOM_DIR)) {
BLI_snprintf(seq->strip->proxy->dir, FILE_MAXDIR, "%s" SEP_STR "BL_proxy", seq->strip->dir);
SNPRINTF(seq->strip->proxy->dir, "%s" SEP_STR "BL_proxy", seq->strip->dir);
}
#undef SEQ_USE_PROXY_CUSTOM_DIR
#undef SEQ_USE_PROXY_CUSTOM_FILE

Some files were not shown because too many files have changed in this diff Show More