[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [58658] trunk/blender/source/blender/imbuf /intern/thumbs.c: code cleanup for thumbnails:

Campbell Barton ideasman42 at gmail.com
Sat Jul 27 11:26:23 CEST 2013


Revision: 58658
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=58658
Author:   campbellbarton
Date:     2013-07-27 09:26:22 +0000 (Sat, 27 Jul 2013)
Log Message:
-----------
code cleanup for thumbnails:
- use URI_MAX define
- replace strcat with BLI_snprintf.

Modified Paths:
--------------
    trunk/blender/source/blender/imbuf/intern/thumbs.c

Modified: trunk/blender/source/blender/imbuf/intern/thumbs.c
===================================================================
--- trunk/blender/source/blender/imbuf/intern/thumbs.c	2013-07-27 09:20:10 UTC (rev 58657)
+++ trunk/blender/source/blender/imbuf/intern/thumbs.c	2013-07-27 09:26:22 UTC (rev 58658)
@@ -67,7 +67,7 @@
 #  include <unistd.h>
 #endif
 
-#define URI_MAX FILE_MAX * 3 + 8
+#define URI_MAX (FILE_MAX * 3 + 8)
 
 static int get_thumb_dir(char *dir, ThumbSize size)
 {
@@ -200,20 +200,20 @@
 		strcat(orig_uri, vol);
 		dirstart += 2;
 	}
+	strcat(orig_uri, dirstart);
+	BLI_char_switch(orig_uri, '\\', '/');
 #else
-	BLI_strncpy(orig_uri, "file://", FILE_MAX);
+	BLI_snprintf(orig_uri, URI_MAX, "file://%s", dirstart);
 #endif
-	strcat(orig_uri, dirstart);
-	BLI_char_switch(orig_uri, '\\', '/');
 	
 #ifdef WITH_ICONV
 	{
-		char uri_utf8[FILE_MAX * 3 + 8];
-		escape_uri_string(orig_uri, uri_utf8, FILE_MAX * 3 + 8, UNSAFE_PATH);
+		char uri_utf8[URI_MAX];
+		escape_uri_string(orig_uri, uri_utf8, URI_MAX, UNSAFE_PATH);
 		BLI_string_to_utf8(uri_utf8, uri, NULL);
 	}
 #else 
-	escape_uri_string(orig_uri, uri, FILE_MAX * 3 + 8, UNSAFE_PATH);
+	escape_uri_string(orig_uri, uri, URI_MAX, UNSAFE_PATH);
 #endif
 	return 1;
 }
@@ -401,7 +401,7 @@
 ImBuf *IMB_thumb_read(const char *path, ThumbSize size)
 {
 	char thumb[FILE_MAX];
-	char uri[FILE_MAX * 3 + 8];
+	char uri[URI_MAX];
 	ImBuf *img = NULL;
 
 	if (!uri_from_filename(path, uri)) {
@@ -418,7 +418,7 @@
 void IMB_thumb_delete(const char *path, ThumbSize size)
 {
 	char thumb[FILE_MAX];
-	char uri[FILE_MAX * 3 + 8];
+	char uri[URI_MAX];
 
 	if (!uri_from_filename(path, uri)) {
 		return;
@@ -438,7 +438,7 @@
 ImBuf *IMB_thumb_manage(const char *path, ThumbSize size, ThumbSource source)
 {
 	char thumb[FILE_MAX];
-	char uri[FILE_MAX * 3 + 8];
+	char uri[URI_MAX];
 	struct stat st;
 	ImBuf *img = NULL;
 	




More information about the Bf-blender-cvs mailing list