Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2012-04-17 23:51:40 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-04-17 23:51:40 +0400
commit149c52859b798230335f9316893891af057191aa (patch)
tree898692b2cb3fda8e620da17c455242e9be289eff /source/blender/blenloader
parent830013aabe3e01b5bc168b93ce7a5074c7ce21ab (diff)
code cleanup: use const args for writing files.
Diffstat (limited to 'source/blender/blenloader')
-rw-r--r--source/blender/blenloader/BLO_undofile.h2
-rw-r--r--source/blender/blenloader/BLO_writefile.h2
-rw-r--r--source/blender/blenloader/intern/undofile.c10
-rw-r--r--source/blender/blenloader/intern/writefile.c28
4 files changed, 22 insertions, 20 deletions
diff --git a/source/blender/blenloader/BLO_undofile.h b/source/blender/blenloader/BLO_undofile.h
index f3c16e07c62..f716b47ea2e 100644
--- a/source/blender/blenloader/BLO_undofile.h
+++ b/source/blender/blenloader/BLO_undofile.h
@@ -47,7 +47,7 @@ typedef struct MemFile {
} MemFile;
/* actually only used writefile.c */
-extern void add_memfilechunk(MemFile *compare, MemFile *current, char *buf, unsigned int size);
+extern void add_memfilechunk(MemFile *compare, MemFile *current, const char *buf, unsigned int size);
/* exports */
extern void BLO_free_memfile(MemFile *memfile);
diff --git a/source/blender/blenloader/BLO_writefile.h b/source/blender/blenloader/BLO_writefile.h
index 90e8c3e211e..7a8429afec0 100644
--- a/source/blender/blenloader/BLO_writefile.h
+++ b/source/blender/blenloader/BLO_writefile.h
@@ -37,7 +37,7 @@ struct MemFile;
struct Main;
struct ReportList;
-extern int BLO_write_file(struct Main *mainvar, const char *filepath, int write_flags, struct ReportList *reports, int *thumb);
+extern int BLO_write_file(struct Main *mainvar, const char *filepath, int write_flags, struct ReportList *reports, const int *thumb);
extern int BLO_write_file_mem(struct Main *mainvar, struct MemFile *compare, struct MemFile *current, int write_flags);
#define BLEN_THUMB_SIZE 128
diff --git a/source/blender/blenloader/intern/undofile.c b/source/blender/blenloader/intern/undofile.c
index eeeaae937b1..75fa8d0c3d2 100644
--- a/source/blender/blenloader/intern/undofile.c
+++ b/source/blender/blenloader/intern/undofile.c
@@ -85,9 +85,11 @@ void BLO_merge_memfile(MemFile *first, MemFile *second)
BLO_free_memfile(first);
}
-static int my_memcmp(int *mem1, int *mem2, int len)
+static int my_memcmp(const int *mem1, const int *mem2, const int len)
{
- register int a= len, *mema= mem1, *memb= mem2;
+ register int a = len;
+ register const int *mema = mem1;
+ register const int *memb = mem2;
while (a--) {
if ( *mema != *memb) return 1;
@@ -97,7 +99,7 @@ static int my_memcmp(int *mem1, int *mem2, int len)
return 0;
}
-void add_memfilechunk(MemFile *compare, MemFile *current, char *buf, unsigned int size)
+void add_memfilechunk(MemFile *compare, MemFile *current, const char *buf, unsigned int size)
{
static MemFileChunk *compchunk=NULL;
MemFileChunk *curchunk;
@@ -121,7 +123,7 @@ void add_memfilechunk(MemFile *compare, MemFile *current, char *buf, unsigned in
/* we compare compchunk with buf */
if (compchunk) {
if (compchunk->size == curchunk->size) {
- if ( my_memcmp((int *)compchunk->buf, (int *)buf, size/4)==0) {
+ if (my_memcmp((int *)compchunk->buf, (const int *)buf, size / 4) == 0) {
curchunk->buf= compchunk->buf;
curchunk->ident= 1;
}
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c
index dc5546d38dd..5a8cb2ede20 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -204,7 +204,7 @@ static WriteData *writedata_new(int file)
return wd;
}
-static void writedata_do_write(WriteData *wd, void *mem, int memlen)
+static void writedata_do_write(WriteData *wd, const void *mem, int memlen)
{
if ((wd == NULL) || wd->error || (mem == NULL) || memlen < 1) return;
if (wd->error) return;
@@ -239,7 +239,7 @@ static void writedata_free(WriteData *wd)
#define MYWRITE_FLUSH NULL
-static void mywrite( WriteData *wd, void *adr, int len)
+static void mywrite( WriteData *wd, const void *adr, int len)
{
if (wd->error) return;
@@ -265,7 +265,7 @@ static void mywrite( WriteData *wd, void *adr, int len)
do {
int writelen= MIN2(len, MYWRITE_MAX_CHUNK);
writedata_do_write(wd, adr, writelen);
- adr = (char*)adr + writelen;
+ adr = (const char *)adr + writelen;
len -= writelen;
} while (len > 0);
@@ -354,22 +354,22 @@ static void writestruct(WriteData *wd, int filecode, const char *structname, int
mywrite(wd, adr, bh.len);
}
-static void writedata(WriteData *wd, int filecode, int len, void *adr) /* do not use for structs */
+static void writedata(WriteData *wd, int filecode, int len, const void *adr) /* do not use for structs */
{
BHead bh;
if (adr==NULL) return;
if (len==0) return;
- len+= 3;
- len-= ( len % 4);
+ len += 3;
+ len -= (len % 4);
/* init BHead */
- bh.code= filecode;
- bh.old= adr;
- bh.nr= 1;
- bh.SDNAnr= 0;
- bh.len= len;
+ bh.code = filecode;
+ bh.old = (void *)adr; /* this is safe to cast from const */
+ bh.nr = 1;
+ bh.SDNAnr = 0;
+ bh.len = len;
mywrite(wd, &bh, sizeof(BHead));
if (len) mywrite(wd, adr, len);
@@ -2764,7 +2764,7 @@ static void write_global(WriteData *wd, int fileflags, Main *mainvar)
* second are an RGBA image (unsigned char)
* note, this uses 'TEST' since new types will segfault on file load for older blender versions.
*/
-static void write_thumb(WriteData *wd, int *img)
+static void write_thumb(WriteData *wd, const int *img)
{
if (img)
writedata(wd, TEST, (2 + img[0] * img[1]) * sizeof(int), img);
@@ -2772,7 +2772,7 @@ static void write_thumb(WriteData *wd, int *img)
/* if MemFile * there's filesave to memory */
static int write_file_handle(Main *mainvar, int handle, MemFile *compare, MemFile *current,
- int write_user_block, int write_flags, int *thumb)
+ int write_user_block, int write_flags, const int *thumb)
{
BHead bhead;
ListBase mainlist;
@@ -2880,7 +2880,7 @@ static int do_history(const char *name, ReportList *reports)
}
/* return: success (1) */
-int BLO_write_file(Main *mainvar, const char *filepath, int write_flags, ReportList *reports, int *thumb)
+int BLO_write_file(Main *mainvar, const char *filepath, int write_flags, ReportList *reports, const int *thumb)
{
char userfilename[FILE_MAX];
char tempname[FILE_MAX+1];