Commit: b2906c2a4af93346c3a208f127f5e2b8fc77406a
Author: Campbell Barton
Date:   Fri Feb 22 09:21:23 2019 +1100
Branches: master
https://developer.blender.org/rBb2906c2a4af93346c3a208f127f5e2b8fc77406a

Cleanup: comments, use bool for 'eof' variable

Also remove unused members headerdone, inbuffer & filedes,
use typed enum for file data flags.

===================================================================

M       source/blender/blenloader/intern/readfile.c
M       source/blender/blenloader/intern/readfile.h

===================================================================

diff --git a/source/blender/blenloader/intern/readfile.c 
b/source/blender/blenloader/intern/readfile.c
index 310c6876b2f..2babe287336 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -726,7 +726,7 @@ static BHeadN *get_bhead(FileData *fd)
        int readsize;
 
        if (fd) {
-               if (!fd->eof) {
+               if (!fd->is_eof) {
                        /* initializing to zero isn't strictly needed but shuts 
valgrind up
                         * since uninitialized memory gets compared */
                        BHead8 bhead8 = {0};
@@ -759,7 +759,7 @@ static BHeadN *get_bhead(FileData *fd)
                                        }
                                }
                                else {
-                                       fd->eof = 1;
+                                       fd->is_eof = true;
                                        bhead.len = 0;
                                }
                        }
@@ -782,18 +782,20 @@ static BHeadN *get_bhead(FileData *fd)
                                        }
                                }
                                else {
-                                       fd->eof = 1;
+                                       fd->is_eof = true;
                                        bhead.len = 0;
                                }
                        }
 
                        /* make sure people are not trying to pass bad blend 
files */
-                       if (bhead.len < 0) fd->eof = 1;
+                       if (bhead.len < 0) {
+                               fd->is_eof = true;
+                       }
 
                        /* bhead now contains the (converted) bhead structure. 
Now read
                         * the associated data and put everything in a BHeadN 
(creative naming !)
                         */
-                       if (!fd->eof) {
+                       if (!fd->is_eof) {
                                new_bhead = MEM_mallocN(sizeof(BHeadN) + 
bhead.len, "new_bhead");
                                if (new_bhead) {
                                        new_bhead->next = new_bhead->prev = 
NULL;
@@ -802,13 +804,13 @@ static BHeadN *get_bhead(FileData *fd)
                                        readsize = fd->read(fd, new_bhead + 1, 
bhead.len);
 
                                        if (readsize != bhead.len) {
-                                               fd->eof = 1;
+                                               fd->is_eof = true;
                                                MEM_freeN(new_bhead);
                                                new_bhead = NULL;
                                        }
                                }
                                else {
-                                       fd->eof = 1;
+                                       fd->is_eof = true;
                                }
                        }
                }
@@ -821,7 +823,7 @@ static BHeadN *get_bhead(FileData *fd)
                BLI_addtail(&fd->listbase, new_bhead);
        }
 
-       return(new_bhead);
+       return new_bhead;
 }
 
 BHead *blo_firstbhead(FileData *fd)
@@ -841,7 +843,7 @@ BHead *blo_firstbhead(FileData *fd)
                bhead = &new_bhead->bhead;
        }
 
-       return(bhead);
+       return bhead;
 }
 
 BHead *blo_prevbhead(FileData *UNUSED(fd), BHead *thisblock)
@@ -875,7 +877,7 @@ BHead *blo_nextbhead(FileData *fd, BHead *thisblock)
                bhead = &new_bhead->bhead;
        }
 
-       return(bhead);
+       return bhead;
 }
 
 /* Warning! Caller's responsibility to ensure given bhead **is** and ID one! */
@@ -1106,7 +1108,6 @@ static FileData *filedata_new(void)
 {
        FileData *fd = MEM_callocN(sizeof(FileData), "FileData");
 
-       fd->filedes = -1;
        fd->gzfiledes = NULL;
 
        fd->memsdna = DNA_sdna_current_get();
diff --git a/source/blender/blenloader/intern/readfile.h 
b/source/blender/blenloader/intern/readfile.h
index c9ce4adc2a5..a6ef5191371 100644
--- a/source/blender/blenloader/intern/readfile.h
+++ b/source/blender/blenloader/intern/readfile.h
@@ -38,44 +38,54 @@ struct PartEff;
 struct ReportList;
 struct View3D;
 
+enum eFileDataFlag {
+       FD_FLAGS_SWITCH_ENDIAN         = 1 << 0,
+       FD_FLAGS_FILE_POINTSIZE_IS_4   = 1 << 1,
+       FD_FLAGS_POINTSIZE_DIFFERS     = 1 << 2,
+       FD_FLAGS_FILE_OK               = 1 << 3,
+       FD_FLAGS_NOT_MY_BUFFER         = 1 << 4,
+       /* XXX Unused in practice (checked once but never set). */
+       FD_FLAGS_NOT_MY_LIBMAP         = 1 << 5,
+};
+
 typedef struct FileData {
-       // linked list of BHeadN's
+       /** Linked list of BHeadN's. */
        ListBase listbase;
-       int flags;
-       int eof;
+       enum eFileDataFlag flags;
+       bool is_eof;
        int buffersize;
        int seek;
        int (*read)(struct FileData *filedata, void *buffer, unsigned int size);
 
-       // variables needed for reading from memory / stream
+       /** Variables needed for reading from memory / stream. */
        const char *buffer;
-       // variables needed for reading from memfile (undo)
+       /** Variables needed for reading from memfile (undo). */
        struct MemFile *memfile;
 
-       // variables needed for reading from file
+       /** Variables needed for reading from file. */
        int filedes;
        gzFile gzfiledes;
 
-       // now only in use for library appending
+       /** Now only in use for library appending. */
        char relabase[FILE_MAX];
 
-       // variables needed for reading from stream
-       char headerdone;
-       int inbuffer;
-
-       // gzip stream for memory decompression
+       /** Gzip stream for memory decompression. */
        z_stream strm;
 
-       // general reading variables
+       /** General reading variables. */
        struct SDNA *filesdna;
        const struct SDNA *memsdna;
-       const char *compflags;  /* array of eSDNA_StructCompare */
+       /** Array of #eSDNA_StructCompare. */
+       const char *compflags;
 
        int fileversion;
-       int id_name_offs;       /* used to retrieve ID names from (bhead+1) */
-       int globalf, fileflags; /* for do_versions patching */
+       /** Used to retrieve ID names from (bhead+1). */
+       int id_name_offs;
+       /** For do_versions patching. */
+       int globalf, fileflags;
 
-       eBLOReadSkip skip_flags;  /* skip some data-blocks */
+       /** Optionally skip some data-blocks when they're not needed. */
+       eBLOReadSkip skip_flags;
 
        struct OldNewMap *datamap;
        struct OldNewMap *globmap;
@@ -89,11 +99,12 @@ typedef struct FileData {
        struct BHeadSort *bheadmap;
        int tot_bheadmap;
 
-       /* see: USE_GHASH_BHEAD */
+       /** See: #USE_GHASH_BHEAD. */
        struct GHash *bhead_idname_hash;
 
        ListBase *mainlist;
-       ListBase *old_mainlist;  /* Used for undo. */
+       /** Used for undo. */
+       ListBase *old_mainlist;
 
        struct ReportList *reports;
 } FileData;
@@ -103,16 +114,6 @@ typedef struct BHeadN {
        struct BHead bhead;
 } BHeadN;
 
-/* FileData->flags */
-enum {
-       FD_FLAGS_SWITCH_ENDIAN         = 1 << 0,
-       FD_FLAGS_FILE_POINTSIZE_IS_4   = 1 << 1,
-       FD_FLAGS_POINTSIZE_DIFFERS     = 1 << 2,
-       FD_FLAGS_FILE_OK               = 1 << 3,
-       FD_FLAGS_NOT_MY_BUFFER         = 1 << 4,
-       FD_FLAGS_NOT_MY_LIBMAP         = 1 << 5,  /* XXX Unused in practice 
(checked once but never set). */
-};
-
 #define SIZEOFBLENDERHEADER 12
 
 /***/

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to