Cleanup: use term SIZE instead of LEN for defines for buffer sizes
Reserve "LEN" for lengths that don't include the null byte.
This commit is contained in:
parent
9cbe156d6a
commit
82d9eb09db
@ -39,7 +39,7 @@ bool BLI_uuid_equal(bUUID uuid1, bUUID uuid2);
|
||||
/**
|
||||
* Format UUID as string.
|
||||
* The buffer must be at least 37 bytes (36 bytes for the UUID + terminating 0).
|
||||
* Use `UUID_STRING_LEN` from DNA_uuid_types.h if you want to use a constant for this.
|
||||
* Use `UUID_STRING_SIZE` from DNA_uuid_types.h if you want to use a constant for this.
|
||||
*/
|
||||
void BLI_uuid_format(char *buffer, bUUID uuid) ATTR_NONNULL();
|
||||
|
||||
|
@ -90,7 +90,7 @@ void BLI_uuid_format(char *buffer, const bUUID uuid)
|
||||
{
|
||||
const size_t buffer_len_unclamped = BLI_snprintf(
|
||||
buffer,
|
||||
UUID_STRING_LEN,
|
||||
UUID_STRING_SIZE,
|
||||
"%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
|
||||
uuid.time_low,
|
||||
uuid.time_mid,
|
||||
@ -105,7 +105,7 @@ void BLI_uuid_format(char *buffer, const bUUID uuid)
|
||||
uuid.node[5]);
|
||||
|
||||
/* Assert the string length is not clamped. */
|
||||
BLI_assert(buffer_len_unclamped == UUID_STRING_LEN - 1);
|
||||
BLI_assert(buffer_len_unclamped == UUID_STRING_SIZE - 1);
|
||||
UNUSED_VARS_NDEBUG(buffer_len_unclamped);
|
||||
}
|
||||
|
||||
|
@ -268,7 +268,7 @@ struct AssetEntryWriter {
|
||||
|
||||
void add_catalog_id(const CatalogID &catalog_id)
|
||||
{
|
||||
char catalog_id_str[UUID_STRING_LEN];
|
||||
char catalog_id_str[UUID_STRING_SIZE];
|
||||
BLI_uuid_format(catalog_id_str, catalog_id);
|
||||
attributes.append_as(std::pair(ATTRIBUTE_ENTRIES_CATALOG_ID, new StringValue(catalog_id_str)));
|
||||
}
|
||||
|
@ -1937,7 +1937,7 @@ struct Panel *UI_panel_add_instanced(const struct bContext *C,
|
||||
*/
|
||||
void UI_panels_free_instanced(const struct bContext *C, struct ARegion *region);
|
||||
|
||||
#define INSTANCED_PANEL_UNIQUE_STR_LEN 16
|
||||
#define INSTANCED_PANEL_UNIQUE_STR_SIZE 16
|
||||
/**
|
||||
* Find a unique key to append to the #PanelType.idname for the lookup to the panel's #uiBlock.
|
||||
* Needed for instanced panels, where there can be multiple with the same type and identifier.
|
||||
|
@ -283,7 +283,7 @@ void UI_list_panel_unique_str(Panel *panel, char *r_name)
|
||||
{
|
||||
/* The panel sort-order will be unique for a specific panel type because the instanced
|
||||
* panel list is regenerated for every change in the data order / length. */
|
||||
BLI_snprintf(r_name, INSTANCED_PANEL_UNIQUE_STR_LEN, "%d", panel->sortorder);
|
||||
BLI_snprintf(r_name, INSTANCED_PANEL_UNIQUE_STR_SIZE, "%d", panel->sortorder);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2695,7 +2695,7 @@ static void ed_panel_draw(const bContext *C,
|
||||
const uiStyle *style = UI_style_get_dpi();
|
||||
|
||||
/* Draw panel. */
|
||||
char block_name[BKE_ST_MAXNAME + INSTANCED_PANEL_UNIQUE_STR_LEN];
|
||||
char block_name[BKE_ST_MAXNAME + INSTANCED_PANEL_UNIQUE_STR_SIZE];
|
||||
if (unique_panel_str) {
|
||||
/* Instanced panels should have already been added at this point. */
|
||||
BLI_string_join(block_name, sizeof(block_name), pt->idname, unique_panel_str);
|
||||
@ -3019,7 +3019,7 @@ void ED_region_panels_layout_ex(const bContext *C,
|
||||
|
||||
/* Use a unique identifier for instanced panels, otherwise an old block for a different
|
||||
* panel of the same type might be found. */
|
||||
char unique_panel_str[INSTANCED_PANEL_UNIQUE_STR_LEN];
|
||||
char unique_panel_str[INSTANCED_PANEL_UNIQUE_STR_SIZE];
|
||||
UI_list_panel_unique_str(panel, unique_panel_str);
|
||||
ed_panel_draw(C,
|
||||
region,
|
||||
|
@ -301,7 +301,7 @@ void AssetCatalogTreeViewItem::build_context_menu(bContext &C, uiLayout &column)
|
||||
&props);
|
||||
RNA_string_set(&props, "parent_path", catalog_item_.catalog_path().c_str());
|
||||
|
||||
char catalog_id_str_buffer[UUID_STRING_LEN] = "";
|
||||
char catalog_id_str_buffer[UUID_STRING_SIZE] = "";
|
||||
BLI_uuid_format(catalog_id_str_buffer, catalog_item_.get_catalog_id());
|
||||
uiItemFullO(&column,
|
||||
"ASSET_OT_catalog_delete",
|
||||
|
@ -32,7 +32,7 @@ typedef struct bUUID {
|
||||
* Memory required for a string representation of a UUID according to RFC4122.
|
||||
* This is 36 characters for the string + a trailing zero byte.
|
||||
*/
|
||||
#define UUID_STRING_LEN 37
|
||||
#define UUID_STRING_SIZE 37
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -293,7 +293,7 @@ static void rna_AssetMetaData_catalog_id_get(PointerRNA *ptr, char *value)
|
||||
|
||||
static int rna_AssetMetaData_catalog_id_length(PointerRNA *UNUSED(ptr))
|
||||
{
|
||||
return UUID_STRING_LEN - 1;
|
||||
return UUID_STRING_SIZE - 1;
|
||||
}
|
||||
|
||||
static void rna_AssetMetaData_catalog_id_set(PointerRNA *ptr, const char *value)
|
||||
|
@ -3350,7 +3350,7 @@ static void rna_FileAssetSelectParams_catalog_id_get(PointerRNA *ptr, char *valu
|
||||
|
||||
static int rna_FileAssetSelectParams_catalog_id_length(PointerRNA * /*ptr*/)
|
||||
{
|
||||
return UUID_STRING_LEN - 1;
|
||||
return UUID_STRING_SIZE - 1;
|
||||
}
|
||||
|
||||
static void rna_FileAssetSelectParams_catalog_id_set(PointerRNA *ptr, const char *value)
|
||||
|
Loading…
Reference in New Issue
Block a user