]> wimlib.net Git - wimlib/blobdiff - include/wimlib/inode.h
Save memory by avoiding padding after sha1_hash fields
[wimlib] / include / wimlib / inode.h
index 08f414d0d7ca6857b90dbffa0396fabfd59784a0..777a05b5440501e66a247bc99bef57d10e9ee835 100644 (file)
@@ -70,7 +70,7 @@ struct wim_inode_stream {
        union {
                u8 _stream_hash[SHA1_HASH_SIZE];
                struct blob_descriptor *_stream_blob;
-       };
+       } _packed_attribute; /* union is SHA1_HASH_SIZE bytes */
 
        /* 'stream_resolved' determines whether 'stream_hash' or 'stream_blob'
         * is valid as described above.  */
@@ -157,10 +157,8 @@ struct wim_inode {
 
        /* Corresponds to 'security_id' in `struct wim_dentry_on_disk':  The
         * index of this inode's security descriptor in the WIM image's table of
-        * security descriptors, or -1.  Note: when a WIM image is loaded,
-        * wimlib sets out-of-bounds indices and values less than -1 in this
-        * field to -1.  So the extraction code need not do an upper bound check
-        * after checking for -1 (or equivalently < 0).  */
+        * security descriptors, or -1 if this inode does not have a security
+        * descriptor.  */
        s32 i_security_id;
 
        /* Unknown field that we only read into memory so we can re-write it
@@ -324,6 +322,13 @@ inode_has_children(const struct wim_inode *inode)
        return inode->i_children != NULL;
 }
 
+/* Does the inode have a security descriptor?  */
+static inline bool
+inode_has_security_descriptor(const struct wim_inode *inode)
+{
+       return inode->i_security_id >= 0;
+}
+
 extern struct wim_inode_stream *
 inode_get_stream(const struct wim_inode *inode, int stream_type,
                 const utf16lechar *stream_name);