[Bf-blender-cvs] [d583455c7f6] soc-2020-info-editor: Simplification: use BLI_sprintfN instead of dynstr...
Bastien Montagne
noreply at git.blender.org
Wed Jul 29 16:26:35 CEST 2020
Commit: d583455c7f61aac5e9563f92cfbb529f76f41fe9
Author: Bastien Montagne
Date: Wed Jul 29 16:26:03 2020 +0200
Branches: soc-2020-info-editor
https://developer.blender.org/rBd583455c7f61aac5e9563f92cfbb529f76f41fe9
Simplification: use BLI_sprintfN instead of dynstr...
===================================================================
M source/blender/blenfont/intern/blf.c
===================================================================
diff --git a/source/blender/blenfont/intern/blf.c b/source/blender/blenfont/intern/blf.c
index 197f98d20d4..a291b31a810 100644
--- a/source/blender/blenfont/intern/blf.c
+++ b/source/blender/blenfont/intern/blf.c
@@ -43,6 +43,7 @@
#include "DNA_vec_types.h"
#include "BLI_math.h"
+#include "BLI_string.h"
#include "BLI_threads.h"
#include "BLF_api.h"
@@ -1006,35 +1007,30 @@ void BLF_draw_buffer(int fontid, const char *str, size_t len)
char *BLF_state_sprintN(int fontid)
{
- DynStr *message = BLI_dynstr_new();
FontBLF *font = blf_get(fontid);
- if (font) {
- BLI_dynstr_appendf(message,
- "fontid %d %p\n"
- " name: '%s'\n"
- " size: %u\n"
- " dpi: %u\n"
- " pos: %.6f %.6f %.6f\n"
- " aspect: (%d) %.6f %.6f %.6f\n"
- " angle: (%d) %.6f\n"
- " flag: %d",
- fontid,
- (void *)font,
- font->name,
- font->size,
- font->dpi,
- UNPACK3(font->pos),
- (font->flags & BLF_ROTATION) != 0,
- UNPACK3(font->aspect),
- (font->flags & BLF_ASPECT) != 0,
- font->angle,
- font->flags);
+ if (font != NULL) {
+ return BLI_sprintfN(
+ "fontid %d %p\n"
+ " name: '%s'\n"
+ " size: %u\n"
+ " dpi: %u\n"
+ " pos: %.6f %.6f %.6f\n"
+ " aspect: (%d) %.6f %.6f %.6f\n"
+ " angle: (%d) %.6f\n"
+ " flag: %d",
+ fontid,
+ (void *)font,
+ font->name,
+ font->size,
+ font->dpi,
+ UNPACK3(font->pos),
+ (font->flags & BLF_ROTATION) != 0,
+ UNPACK3(font->aspect),
+ (font->flags & BLF_ASPECT) != 0,
+ font->angle,
+ font->flags);
}
else {
- BLI_dynstr_appendf(message, "fontid %d (NULL)", fontid);
+ return BLI_sprintfN("fontid %d (NULL)", fontid);
}
-
- char *cstring = BLI_dynstr_get_cstring(message);
- BLI_dynstr_free(message);
- return cstring;
}
More information about the Bf-blender-cvs
mailing list