lucy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mar...@apache.org
Subject [lucy-commits] [17/34] git commit: refs/heads/master - Migrate Lucy's store classes to IVARS.
Date Wed, 17 Jul 2013 14:12:37 GMT
Migrate Lucy's store classes to IVARS.

Change all Lucy's store classes to access instance vars via an IVARS
struct rather than via `self`.


Project: http://git-wip-us.apache.org/repos/asf/lucy/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy/commit/d04580a1
Tree: http://git-wip-us.apache.org/repos/asf/lucy/tree/d04580a1
Diff: http://git-wip-us.apache.org/repos/asf/lucy/diff/d04580a1

Branch: refs/heads/master
Commit: d04580a14c75c2fc4fa2eb684f13069607dbffe1
Parents: 474e8b4
Author: Marvin Humphrey <marvin@rectangular.com>
Authored: Fri Jun 28 14:07:41 2013 -0700
Committer: Marvin Humphrey <marvin@rectangular.com>
Committed: Tue Jul 16 16:08:42 2013 -0700

----------------------------------------------------------------------
 core/Lucy/Store/CompoundFileReader.c | 142 ++++++++++++---------
 core/Lucy/Store/CompoundFileWriter.c |  35 +++---
 core/Lucy/Store/DirHandle.c          |  14 ++-
 core/Lucy/Store/FSDirHandle.c        | 121 ++++++++++--------
 core/Lucy/Store/FSFileHandle.c       | 197 ++++++++++++++++-------------
 core/Lucy/Store/FSFolder.c           |  34 +++--
 core/Lucy/Store/FileHandle.c         |  13 +-
 core/Lucy/Store/FileWindow.c         |  16 +--
 core/Lucy/Store/Folder.c             |  27 ++--
 core/Lucy/Store/InStream.c           | 202 +++++++++++++++++-------------
 core/Lucy/Store/Lock.c               |  91 ++++++++------
 core/Lucy/Store/LockFactory.c        |  16 ++-
 core/Lucy/Store/OutStream.c          | 155 +++++++++++++----------
 core/Lucy/Store/RAMDirHandle.c       |  40 +++---
 core/Lucy/Store/RAMFile.c            |  14 ++-
 core/Lucy/Store/RAMFileHandle.c      |  52 ++++----
 core/Lucy/Store/RAMFileHandle.cfh    |   1 +
 core/Lucy/Store/RAMFolder.c          |  50 +++++---
 core/Lucy/Store/SharedLock.c         |  45 ++++---
 19 files changed, 715 insertions(+), 550 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy/blob/d04580a1/core/Lucy/Store/CompoundFileReader.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Store/CompoundFileReader.c b/core/Lucy/Store/CompoundFileReader.c
index 21e08a8..c519498 100644
--- a/core/Lucy/Store/CompoundFileReader.c
+++ b/core/Lucy/Store/CompoundFileReader.c
@@ -35,6 +35,7 @@ CFReader_open(Folder *folder) {
 
 CompoundFileReader*
 CFReader_do_open(CompoundFileReader *self, Folder *folder) {
+    CompoundFileReaderIVARS *const ivars = CFReader_IVARS(self);
     CharBuf *cfmeta_file = (CharBuf*)ZCB_WRAP_STR("cfmeta.json", 11);
     Hash *metadata = (Hash*)Json_slurp_json((Folder*)folder, cfmeta_file);
     Err *error = NULL;
@@ -48,18 +49,18 @@ CFReader_do_open(CompoundFileReader *self, Folder *folder) {
     }
     else {
         Obj *format = Hash_Fetch_Str(metadata, "format", 6);
-        self->format = format ? (int32_t)Obj_To_I64(format) : 0;
-        self->records = (Hash*)INCREF(Hash_Fetch_Str(metadata, "files", 5));
-        if (self->format < 1) {
+        ivars->format = format ? (int32_t)Obj_To_I64(format) : 0;
+        ivars->records = (Hash*)INCREF(Hash_Fetch_Str(metadata, "files", 5));
+        if (ivars->format < 1) {
             error = Err_new(CB_newf("Corrupt %o file: Missing or invalid 'format'",
                                     cfmeta_file));
         }
-        else if (self->format > CFWriter_current_file_format) {
+        else if (ivars->format > CFWriter_current_file_format) {
             error = Err_new(CB_newf("Unsupported compound file format: %i32 "
-                                    "(current = %i32", self->format,
+                                    "(current = %i32", ivars->format,
                                     CFWriter_current_file_format));
         }
-        else if (!self->records) {
+        else if (!ivars->records) {
             error = Err_new(CB_newf("Corrupt %o file: missing 'files' key",
                                     cfmeta_file));
         }
@@ -73,19 +74,19 @@ CFReader_do_open(CompoundFileReader *self, Folder *folder) {
 
     // Open an instream which we'll clone over and over.
     CharBuf *cf_file = (CharBuf*)ZCB_WRAP_STR("cf.dat", 6);
-    self->instream = Folder_Open_In(folder, cf_file);
-    if (!self->instream) {
+    ivars->instream = Folder_Open_In(folder, cf_file);
+    if (!ivars->instream) {
         ERR_ADD_FRAME(Err_get_error());
         DECREF(self);
         return NULL;
     }
 
     // Assign.
-    self->real_folder = (Folder*)INCREF(folder);
+    ivars->real_folder = (Folder*)INCREF(folder);
 
     // Strip directory name from filepaths for old format.
-    if (self->format == 1) {
-        VArray *files = Hash_Keys(self->records);
+    if (ivars->format == 1) {
+        VArray *files = Hash_Keys(ivars->records);
         ZombieCharBuf *filename = ZCB_BLANK();
         ZombieCharBuf *folder_name
             = IxFileNames_local_part(Folder_Get_Path(folder), ZCB_BLANK());
@@ -94,10 +95,10 @@ CFReader_do_open(CompoundFileReader *self, Folder *folder) {
         for (uint32_t i = 0, max = VA_Get_Size(files); i < max; i++) {
             CharBuf *orig = (CharBuf*)VA_Fetch(files, i);
             if (CB_Starts_With(orig, (CharBuf*)folder_name)) {
-                Obj *record = Hash_Delete(self->records, (Obj*)orig);
+                Obj *record = Hash_Delete(ivars->records, (Obj*)orig);
                 ZCB_Assign(filename, orig);
                 ZCB_Nip(filename, folder_name_len + sizeof(DIR_SEP) - 1);
-                Hash_Store(self->records, (Obj*)filename, (Obj*)record);
+                Hash_Store(ivars->records, (Obj*)filename, (Obj*)record);
             }
         }
 
@@ -109,35 +110,38 @@ CFReader_do_open(CompoundFileReader *self, Folder *folder) {
 
 void
 CFReader_destroy(CompoundFileReader *self) {
-    DECREF(self->real_folder);
-    DECREF(self->instream);
-    DECREF(self->records);
+    CompoundFileReaderIVARS *const ivars = CFReader_IVARS(self);
+    DECREF(ivars->real_folder);
+    DECREF(ivars->instream);
+    DECREF(ivars->records);
     SUPER_DESTROY(self, COMPOUNDFILEREADER);
 }
 
 Folder*
 CFReader_get_real_folder(CompoundFileReader *self) {
-    return self->real_folder;
+    return CFReader_IVARS(self)->real_folder;
 }
 
 void
 CFReader_set_path(CompoundFileReader *self, const CharBuf *path) {
-    Folder_Set_Path(self->real_folder, path);
+    CompoundFileReaderIVARS *const ivars = CFReader_IVARS(self);
+    Folder_Set_Path(ivars->real_folder, path);
     Folder_set_path((Folder*)self, path);
 }
 
 FileHandle*
 CFReader_local_open_filehandle(CompoundFileReader *self,
                                const CharBuf *name, uint32_t flags) {
-    Hash *entry = (Hash*)Hash_Fetch(self->records, (Obj*)name);
+    CompoundFileReaderIVARS *const ivars = CFReader_IVARS(self);
+    Hash *entry = (Hash*)Hash_Fetch(ivars->records, (Obj*)name);
     FileHandle *fh = NULL;
 
     if (entry) {
         Err_set_error(Err_new(CB_newf("Can't open FileHandle for virtual file %o in '%o'",
-                                      name, self->path)));
+                                      name, ivars->path)));
     }
     else {
-        fh = Folder_Local_Open_FileHandle(self->real_folder, name, flags);
+        fh = Folder_Local_Open_FileHandle(ivars->real_folder, name, flags);
         if (!fh) {
             ERR_ADD_FRAME(Err_get_error());
         }
@@ -148,22 +152,23 @@ CFReader_local_open_filehandle(CompoundFileReader *self,
 
 bool
 CFReader_local_delete(CompoundFileReader *self, const CharBuf *name) {
-    Hash *record = (Hash*)Hash_Delete(self->records, (Obj*)name);
+    CompoundFileReaderIVARS *const ivars = CFReader_IVARS(self);
+    Hash *record = (Hash*)Hash_Delete(ivars->records, (Obj*)name);
     DECREF(record);
 
     if (record == NULL) {
-        return Folder_Local_Delete(self->real_folder, name);
+        return Folder_Local_Delete(ivars->real_folder, name);
     }
     else {
         // Once the number of virtual files falls to 0, remove the compound
         // files.
-        if (Hash_Get_Size(self->records) == 0) {
+        if (Hash_Get_Size(ivars->records) == 0) {
             CharBuf *cf_file = (CharBuf*)ZCB_WRAP_STR("cf.dat", 6);
-            if (!Folder_Delete(self->real_folder, cf_file)) {
+            if (!Folder_Delete(ivars->real_folder, cf_file)) {
                 return false;
             }
             CharBuf *cfmeta_file = (CharBuf*)ZCB_WRAP_STR("cfmeta.json", 11);
-            if (!Folder_Delete(self->real_folder, cfmeta_file)) {
+            if (!Folder_Delete(ivars->real_folder, cfmeta_file)) {
                 return false;
 
             }
@@ -174,10 +179,11 @@ CFReader_local_delete(CompoundFileReader *self, const CharBuf *name) {
 
 InStream*
 CFReader_local_open_in(CompoundFileReader *self, const CharBuf *name) {
-    Hash *entry = (Hash*)Hash_Fetch(self->records, (Obj*)name);
+    CompoundFileReaderIVARS *const ivars = CFReader_IVARS(self);
+    Hash *entry = (Hash*)Hash_Fetch(ivars->records, (Obj*)name);
 
     if (!entry) {
-        InStream *instream = Folder_Local_Open_In(self->real_folder, name);
+        InStream *instream = Folder_Local_Open_In(ivars->real_folder, name);
         if (!instream) {
             ERR_ADD_FRAME(Err_get_error());
         }
@@ -188,18 +194,18 @@ CFReader_local_open_in(CompoundFileReader *self, const CharBuf *name) {
         Obj *offset = Hash_Fetch_Str(entry, "offset", 6);
         if (!len || !offset) {
             Err_set_error(Err_new(CB_newf("Malformed entry for '%o' in '%o'",
-                                          name, Folder_Get_Path(self->real_folder))));
+                                          name, Folder_Get_Path(ivars->real_folder))));
             return NULL;
         }
-        else if (CB_Get_Size(self->path)) {
-            CharBuf *fullpath = CB_newf("%o/%o", self->path, name);
-            InStream *instream = InStream_Reopen(self->instream, fullpath,
+        else if (CB_Get_Size(ivars->path)) {
+            CharBuf *fullpath = CB_newf("%o/%o", ivars->path, name);
+            InStream *instream = InStream_Reopen(ivars->instream, fullpath,
                                                  Obj_To_I64(offset), Obj_To_I64(len));
             DECREF(fullpath);
             return instream;
         }
         else {
-            return InStream_Reopen(self->instream, name, Obj_To_I64(offset),
+            return InStream_Reopen(ivars->instream, name, Obj_To_I64(offset),
                                    Obj_To_I64(len));
         }
     }
@@ -207,31 +213,35 @@ CFReader_local_open_in(CompoundFileReader *self, const CharBuf *name) {
 
 bool
 CFReader_local_exists(CompoundFileReader *self, const CharBuf *name) {
-    if (Hash_Fetch(self->records, (Obj*)name))        { return true; }
-    if (Folder_Local_Exists(self->real_folder, name)) { return true; }
+    CompoundFileReaderIVARS *const ivars = CFReader_IVARS(self);
+    if (Hash_Fetch(ivars->records, (Obj*)name))        { return true; }
+    if (Folder_Local_Exists(ivars->real_folder, name)) { return true; }
     return false;
 }
 
 bool
 CFReader_local_is_directory(CompoundFileReader *self, const CharBuf *name) {
-    if (Hash_Fetch(self->records, (Obj*)name))              { return false; }
-    if (Folder_Local_Is_Directory(self->real_folder, name)) { return true; }
+    CompoundFileReaderIVARS *const ivars = CFReader_IVARS(self);
+    if (Hash_Fetch(ivars->records, (Obj*)name))              { return false; }
+    if (Folder_Local_Is_Directory(ivars->real_folder, name)) { return true; }
     return false;
 }
 
 void
 CFReader_close(CompoundFileReader *self) {
-    InStream_Close(self->instream);
+    CompoundFileReaderIVARS *const ivars = CFReader_IVARS(self);
+    InStream_Close(ivars->instream);
 }
 
 bool
 CFReader_local_mkdir(CompoundFileReader *self, const CharBuf *name) {
-    if (Hash_Fetch(self->records, (Obj*)name)) {
+    CompoundFileReaderIVARS *const ivars = CFReader_IVARS(self);
+    if (Hash_Fetch(ivars->records, (Obj*)name)) {
         Err_set_error(Err_new(CB_newf("Can't MkDir: '%o' exists", name)));
         return false;
     }
     else {
-        bool result = Folder_Local_MkDir(self->real_folder, name);
+        bool result = Folder_Local_MkDir(ivars->real_folder, name);
         if (!result) { ERR_ADD_FRAME(Err_get_error()); }
         return result;
     }
@@ -239,8 +249,9 @@ CFReader_local_mkdir(CompoundFileReader *self, const CharBuf *name) {
 
 Folder*
 CFReader_local_find_folder(CompoundFileReader *self, const CharBuf *name) {
-    if (Hash_Fetch(self->records, (Obj*)name)) { return false; }
-    return Folder_Local_Find_Folder(self->real_folder, name);
+    CompoundFileReaderIVARS *const ivars = CFReader_IVARS(self);
+    if (Hash_Fetch(ivars->records, (Obj*)name)) { return false; }
+    return Folder_Local_Find_Folder(ivars->real_folder, name);
 }
 
 DirHandle*
@@ -260,14 +271,18 @@ CFReaderDH_new(CompoundFileReader *cf_reader) {
 CFReaderDirHandle*
 CFReaderDH_init(CFReaderDirHandle *self, CompoundFileReader *cf_reader) {
     DH_init((DirHandle*)self, CFReader_Get_Path(cf_reader));
-    self->cf_reader = (CompoundFileReader*)INCREF(cf_reader);
-    self->elems  = Hash_Keys(self->cf_reader->records);
-    self->tick   = -1;
+    CFReaderDirHandleIVARS *const ivars = CFReaderDH_IVARS(self);
+    ivars->cf_reader = (CompoundFileReader*)INCREF(cf_reader);
+
+    Hash *cf_records = CFReader_IVARS(ivars->cf_reader)->records;
+    ivars->elems  = Hash_Keys(cf_records);
+    ivars->tick   = -1;
     // Accumulate entries from real Folder.
-    DirHandle *dh = Folder_Local_Open_Dir(self->cf_reader->real_folder);
+    Folder *real_folder = CFReader_Get_Real_Folder(ivars->cf_reader);
+    DirHandle *dh = Folder_Local_Open_Dir(real_folder);
     CharBuf *entry = DH_Get_Entry(dh);
     while (DH_Next(dh)) {
-        VA_Push(self->elems, (Obj*)CB_Clone(entry));
+        VA_Push(ivars->elems, (Obj*)CB_Clone(entry));
     }
     DECREF(dh);
     return self;
@@ -275,29 +290,31 @@ CFReaderDH_init(CFReaderDirHandle *self, CompoundFileReader *cf_reader) {
 
 bool
 CFReaderDH_close(CFReaderDirHandle *self) {
-    if (self->elems) {
-        VA_Dec_RefCount(self->elems);
-        self->elems = NULL;
+    CFReaderDirHandleIVARS *const ivars = CFReaderDH_IVARS(self);
+    if (ivars->elems) {
+        VA_Dec_RefCount(ivars->elems);
+        ivars->elems = NULL;
     }
-    if (self->cf_reader) {
-        CFReader_Dec_RefCount(self->cf_reader);
-        self->cf_reader = NULL;
+    if (ivars->cf_reader) {
+        CFReader_Dec_RefCount(ivars->cf_reader);
+        ivars->cf_reader = NULL;
     }
     return true;
 }
 
 bool
 CFReaderDH_next(CFReaderDirHandle *self) {
-    if (self->elems) {
-        self->tick++;
-        if (self->tick < (int32_t)VA_Get_Size(self->elems)) {
+    CFReaderDirHandleIVARS *const ivars = CFReaderDH_IVARS(self);
+    if (ivars->elems) {
+        ivars->tick++;
+        if (ivars->tick < (int32_t)VA_Get_Size(ivars->elems)) {
             CharBuf *path = (CharBuf*)CERTIFY(
-                                VA_Fetch(self->elems, self->tick), CHARBUF);
-            CB_Mimic(self->entry, (Obj*)path);
+                                VA_Fetch(ivars->elems, ivars->tick), CHARBUF);
+            CB_Mimic(ivars->entry, (Obj*)path);
             return true;
         }
         else {
-            self->tick--;
+            ivars->tick--;
             return false;
         }
     }
@@ -306,10 +323,11 @@ CFReaderDH_next(CFReaderDirHandle *self) {
 
 bool
 CFReaderDH_entry_is_dir(CFReaderDirHandle *self) {
-    if (self->elems) {
-        CharBuf *name = (CharBuf*)VA_Fetch(self->elems, self->tick);
+    CFReaderDirHandleIVARS *const ivars = CFReaderDH_IVARS(self);
+    if (ivars->elems) {
+        CharBuf *name = (CharBuf*)VA_Fetch(ivars->elems, ivars->tick);
         if (name) {
-            return CFReader_Local_Is_Directory(self->cf_reader, name);
+            return CFReader_Local_Is_Directory(ivars->cf_reader, name);
         }
     }
     return false;

http://git-wip-us.apache.org/repos/asf/lucy/blob/d04580a1/core/Lucy/Store/CompoundFileWriter.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Store/CompoundFileWriter.c b/core/Lucy/Store/CompoundFileWriter.c
index 2ff716b..c009e64 100644
--- a/core/Lucy/Store/CompoundFileWriter.c
+++ b/core/Lucy/Store/CompoundFileWriter.c
@@ -28,11 +28,12 @@ int32_t CFWriter_current_file_format = 2;
 
 // Helper which does the heavy lifting for CFWriter_consolidate.
 static void
-S_do_consolidate(CompoundFileWriter *self);
+S_do_consolidate(CompoundFileWriter *self, CompoundFileWriterIVARS *ivars);
 
 // Clean up files which may be left over from previous merge attempts.
 static void
-S_clean_up_old_temp_files(CompoundFileWriter *self);
+S_clean_up_old_temp_files(CompoundFileWriter *self,
+                          CompoundFileWriterIVARS *ivars);
 
 CompoundFileWriter*
 CFWriter_new(Folder *folder) {
@@ -43,32 +44,37 @@ CFWriter_new(Folder *folder) {
 
 CompoundFileWriter*
 CFWriter_init(CompoundFileWriter *self, Folder *folder) {
-    self->folder = (Folder*)INCREF(folder);
+    CompoundFileWriterIVARS *const ivars = CFWriter_IVARS(self);
+    ivars->folder = (Folder*)INCREF(folder);
     return self;
 }
 
 void
 CFWriter_destroy(CompoundFileWriter *self) {
-    DECREF(self->folder);
+    CompoundFileWriterIVARS *const ivars = CFWriter_IVARS(self);
+    DECREF(ivars->folder);
     SUPER_DESTROY(self, COMPOUNDFILEWRITER);
 }
 
 void
 CFWriter_consolidate(CompoundFileWriter *self) {
+    CompoundFileWriterIVARS *const ivars = CFWriter_IVARS(self);
     CharBuf *cfmeta_file = (CharBuf*)ZCB_WRAP_STR("cfmeta.json", 11);
-    if (Folder_Exists(self->folder, cfmeta_file)) {
+    if (Folder_Exists(ivars->folder, cfmeta_file)) {
         THROW(ERR, "Merge already performed for %o",
-              Folder_Get_Path(self->folder));
+              Folder_Get_Path(ivars->folder));
     }
     else {
-        S_clean_up_old_temp_files(self);
-        S_do_consolidate(self);
+        S_clean_up_old_temp_files(self, ivars);
+        S_do_consolidate(self, ivars);
     }
 }
 
 static void
-S_clean_up_old_temp_files(CompoundFileWriter *self) {
-    Folder  *folder      = self->folder;
+S_clean_up_old_temp_files(CompoundFileWriter *self,
+                          CompoundFileWriterIVARS *ivars) {
+    UNUSED_VAR(self);
+    Folder  *folder      = ivars->folder;
     CharBuf *cfmeta_temp = (CharBuf*)ZCB_WRAP_STR("cfmeta.json.temp", 16);
     CharBuf *cf_file     = (CharBuf*)ZCB_WRAP_STR("cf.dat", 6);
 
@@ -85,8 +91,9 @@ S_clean_up_old_temp_files(CompoundFileWriter *self) {
 }
 
 static void
-S_do_consolidate(CompoundFileWriter *self) {
-    Folder    *folder       = self->folder;
+S_do_consolidate(CompoundFileWriter *self, CompoundFileWriterIVARS *ivars) {
+    UNUSED_VAR(self);
+    Folder    *folder       = ivars->folder;
     Hash      *metadata     = Hash_new(0);
     Hash      *sub_files    = Hash_new(0);
     VArray    *files        = Folder_List(folder, NULL);
@@ -143,8 +150,8 @@ S_do_consolidate(CompoundFileWriter *self) {
     // Write metadata to cfmeta file.
     CharBuf *cfmeta_temp = (CharBuf*)ZCB_WRAP_STR("cfmeta.json.temp", 16);
     CharBuf *cfmeta_file = (CharBuf*)ZCB_WRAP_STR("cfmeta.json", 11);
-    Json_spew_json((Obj*)metadata, (Folder*)self->folder, cfmeta_temp);
-    rename_success = Folder_Rename(self->folder, cfmeta_temp, cfmeta_file);
+    Json_spew_json((Obj*)metadata, (Folder*)ivars->folder, cfmeta_temp);
+    rename_success = Folder_Rename(ivars->folder, cfmeta_temp, cfmeta_file);
     if (!rename_success) { RETHROW(INCREF(Err_get_error())); }
 
     // Clean up.

http://git-wip-us.apache.org/repos/asf/lucy/blob/d04580a1/core/Lucy/Store/DirHandle.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Store/DirHandle.c b/core/Lucy/Store/DirHandle.c
index 6729d5d..c9e4b03 100644
--- a/core/Lucy/Store/DirHandle.c
+++ b/core/Lucy/Store/DirHandle.c
@@ -20,28 +20,30 @@
 
 DirHandle*
 DH_init(DirHandle *self, const CharBuf *dir) {
-    self->dir   = CB_Clone(dir);
-    self->entry = CB_new(32);
+    DirHandleIVARS *const ivars = DH_IVARS(self);
+    ivars->dir   = CB_Clone(dir);
+    ivars->entry = CB_new(32);
     ABSTRACT_CLASS_CHECK(self, DIRHANDLE);
     return self;
 }
 
 void
 DH_destroy(DirHandle *self) {
+    DirHandleIVARS *const ivars = DH_IVARS(self);
     DH_Close(self);
-    DECREF(self->dir);
-    DECREF(self->entry);
+    DECREF(ivars->dir);
+    DECREF(ivars->entry);
     SUPER_DESTROY(self, DIRHANDLE);
 }
 
 CharBuf*
 DH_get_dir(DirHandle *self) {
-    return self->dir;
+    return DH_IVARS(self)->dir;
 }
 
 CharBuf*
 DH_get_entry(DirHandle *self) {
-    return self->entry;
+    return DH_IVARS(self)->entry;
 }
 
 

http://git-wip-us.apache.org/repos/asf/lucy/blob/d04580a1/core/Lucy/Store/FSDirHandle.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Store/FSDirHandle.c b/core/Lucy/Store/FSDirHandle.c
index 27ecb59..1d2d118 100644
--- a/core/Lucy/Store/FSDirHandle.c
+++ b/core/Lucy/Store/FSDirHandle.c
@@ -39,8 +39,9 @@ FSDH_open(const CharBuf *dir) {
 void
 FSDH_destroy(FSDirHandle *self) {
     // Throw away saved error -- it's too late to call Close() now.
-    DECREF(self->saved_error);
-    self->saved_error = NULL;
+    FSDirHandleIVARS *const ivars = FSDH_IVARS(self);
+    DECREF(ivars->saved_error);
+    ivars->saved_error = NULL;
     SUPER_DESTROY(self, FSDIRHANDLE);
 }
 
@@ -70,9 +71,10 @@ FSDH_do_open(FSDirHandle *self, const CharBuf *dir) {
     char   *path_ptr = search_string;
 
     DH_init((DirHandle*)self, dir);
-    self->sys_dir_entry    = MALLOCATE(sizeof(WIN32_FIND_DATA));
-    self->sys_dirhandle    = INVALID_HANDLE_VALUE;
-    self->saved_error      = NULL;
+    FSDirHandleIVARS *const ivars = FSDH_IVARS(self);
+    ivars->sys_dir_entry    = MALLOCATE(sizeof(WIN32_FIND_DATA));
+    ivars->sys_dirhandle    = INVALID_HANDLE_VALUE;
+    ivars->saved_error      = NULL;
 
     if (dir_path_size >= MAX_PATH - 2) {
         // Deal with Windows ceiling on file path lengths.
@@ -87,9 +89,9 @@ FSDH_do_open(FSDirHandle *self, const CharBuf *dir) {
     memcpy(path_ptr, dir_path_ptr, dir_path_size);
     memcpy(path_ptr + dir_path_size, "\\*\0", 3);
 
-    self->sys_dirhandle
-        = FindFirstFile(search_string, (WIN32_FIND_DATA*)self->sys_dir_entry);
-    if (INVALID_HANDLE_VALUE == self->sys_dirhandle) {
+    ivars->sys_dirhandle
+        = FindFirstFile(search_string, (WIN32_FIND_DATA*)ivars->sys_dir_entry);
+    if (INVALID_HANDLE_VALUE == ivars->sys_dirhandle) {
         // Directory inaccessible or doesn't exist.
         Err_set_error(Err_new(CB_newf("Failed to open dir '%o'", dir)));
         CFISH_DECREF(self);
@@ -99,7 +101,7 @@ FSDH_do_open(FSDirHandle *self, const CharBuf *dir) {
         // Compensate for the fact that FindFirstFile has already returned the
         // first entry but DirHandle's API requires that you call Next() to
         // start the iterator.
-        self->delayed_iter = true;
+        ivars->delayed_iter = true;
     }
 
     return self;
@@ -107,7 +109,8 @@ FSDH_do_open(FSDirHandle *self, const CharBuf *dir) {
 
 bool
 FSDH_entry_is_dir(FSDirHandle *self) {
-    WIN32_FIND_DATA *find_data = (WIN32_FIND_DATA*)self->sys_dir_entry;
+    FSDirHandleIVARS *const ivars = FSDH_IVARS(self);
+    WIN32_FIND_DATA *find_data = (WIN32_FIND_DATA*)ivars->sys_dir_entry;
     if (find_data) {
         if ((find_data->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
             return true;
@@ -118,7 +121,8 @@ FSDH_entry_is_dir(FSDirHandle *self) {
 
 bool
 FSDH_entry_is_symlink(FSDirHandle *self) {
-    WIN32_FIND_DATA *find_data = (WIN32_FIND_DATA*)self->sys_dir_entry;
+    FSDirHandleIVARS *const ivars = FSDH_IVARS(self);
+    WIN32_FIND_DATA *find_data = (WIN32_FIND_DATA*)ivars->sys_dir_entry;
     if (find_data) {
         if ((find_data->dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT)) {
             return true;
@@ -129,27 +133,28 @@ FSDH_entry_is_symlink(FSDirHandle *self) {
 
 bool
 FSDH_close(FSDirHandle *self) {
-    if (self->sys_dirhandle && self->sys_dirhandle != INVALID_HANDLE_VALUE) {
-        HANDLE dirhandle = (HANDLE)self->sys_dirhandle;
-        self->sys_dirhandle = NULL;
+    FSDirHandleIVARS *const ivars = FSDH_IVARS(self);
+    if (ivars->sys_dirhandle && ivars->sys_dirhandle != INVALID_HANDLE_VALUE) {
+        HANDLE dirhandle = (HANDLE)ivars->sys_dirhandle;
+        ivars->sys_dirhandle = NULL;
         if (dirhandle != INVALID_HANDLE_VALUE && !FindClose(dirhandle)) {
-            if (!self->saved_error) {
+            if (!ivars->saved_error) {
                 char *win_error = Err_win_error();
-                self->saved_error
+                ivars->saved_error
                     = Err_new(CB_newf("Error while closing directory: %s",
                                       win_error));
                 FREEMEM(win_error);
             }
         }
     }
-    if (self->sys_dir_entry) {
-        FREEMEM(self->sys_dir_entry);
-        self->sys_dir_entry = NULL;
+    if (ivars->sys_dir_entry) {
+        FREEMEM(ivars->sys_dir_entry);
+        ivars->sys_dir_entry = NULL;
     }
 
     // If we encountered an error condition previously, report it now.
-    if (self->saved_error) {
-        Err_set_error((Err*)CFISH_INCREF(self->saved_error));
+    if (ivars->saved_error) {
+        Err_set_error((Err*)CFISH_INCREF(ivars->saved_error));
         return false;
     }
     else {
@@ -159,22 +164,23 @@ FSDH_close(FSDirHandle *self) {
 
 bool
 FSDH_next(FSDirHandle *self) {
-    HANDLE           dirhandle = (HANDLE)self->sys_dirhandle;
-    WIN32_FIND_DATA *find_data = (WIN32_FIND_DATA*)self->sys_dir_entry;
+    FSDirHandleIVARS *const ivars = FSDH_IVARS(self);
+    HANDLE           dirhandle = (HANDLE)ivars->sys_dirhandle;
+    WIN32_FIND_DATA *find_data = (WIN32_FIND_DATA*)ivars->sys_dir_entry;
 
     // Attempt to move forward or absorb cached iter.
     if (!dirhandle || dirhandle == INVALID_HANDLE_VALUE) {
         return false;
     }
-    else if (self->delayed_iter) {
-        self->delayed_iter = false;
+    else if (ivars->delayed_iter) {
+        ivars->delayed_iter = false;
     }
     else if ((FindNextFile(dirhandle, find_data) == 0)) {
         // Iterator exhausted.  Verify that no errors were encountered.
-        CB_Set_Size(self->entry, 0);
+        CB_Set_Size(ivars->entry, 0);
         if (GetLastError() != ERROR_NO_MORE_FILES) {
             char *win_error = Err_win_error();
-            self->saved_error
+            ivars->saved_error
                 = Err_new(CB_newf("Error while traversing directory: %s",
                                   win_error));
             FREEMEM(win_error);
@@ -188,7 +194,7 @@ FSDH_next(FSDirHandle *self) {
         return FSDH_Next(self);
     }
     else {
-        CB_Mimic_Str(self->entry, find_data->cFileName, len);
+        CB_Mimic_Str(ivars->entry, find_data->cFileName, len);
         return true;
     }
 }
@@ -203,11 +209,12 @@ FSDH_do_open(FSDirHandle *self, const CharBuf *dir) {
     char *dir_path_ptr = (char*)CB_Get_Ptr8(dir);
 
     DH_init((DirHandle*)self, dir);
-    self->sys_dir_entry    = NULL;
-    self->fullpath         = NULL;
+    FSDirHandleIVARS *const ivars = FSDH_IVARS(self);
+    ivars->sys_dir_entry    = NULL;
+    ivars->fullpath         = NULL;
 
-    self->sys_dirhandle = opendir(dir_path_ptr);
-    if (!self->sys_dirhandle) {
+    ivars->sys_dirhandle = opendir(dir_path_ptr);
+    if (!ivars->sys_dirhandle) {
         Err_set_error(Err_new(CB_newf("Failed to opendir '%o'", dir)));
         DECREF(self);
         return NULL;
@@ -218,13 +225,14 @@ FSDH_do_open(FSDirHandle *self, const CharBuf *dir) {
 
 bool
 FSDH_next(FSDirHandle *self) {
-    self->sys_dir_entry = (struct dirent*)readdir((DIR*)self->sys_dirhandle);
-    if (!self->sys_dir_entry) {
-        CB_Set_Size(self->entry, 0);
+    FSDirHandleIVARS *const ivars = FSDH_IVARS(self);
+    ivars->sys_dir_entry = (struct dirent*)readdir((DIR*)ivars->sys_dirhandle);
+    if (!ivars->sys_dir_entry) {
+        CB_Set_Size(ivars->entry, 0);
         return false;
     }
     else {
-        struct dirent *sys_dir_entry = (struct dirent*)self->sys_dir_entry;
+        struct dirent *sys_dir_entry = (struct dirent*)ivars->sys_dir_entry;
         #ifdef CHY_HAS_DIRENT_D_NAMLEN
         size_t len = sys_dir_entry->d_namlen;
         #else
@@ -234,7 +242,7 @@ FSDH_next(FSDirHandle *self) {
             return FSDH_Next(self);
         }
         else {
-            CB_Mimic_Str(self->entry, sys_dir_entry->d_name, len);
+            CB_Mimic_Str(ivars->entry, sys_dir_entry->d_name, len);
             return true;
         }
     }
@@ -242,7 +250,8 @@ FSDH_next(FSDirHandle *self) {
 
 bool
 FSDH_entry_is_dir(FSDirHandle *self) {
-    struct dirent *sys_dir_entry = (struct dirent*)self->sys_dir_entry;
+    FSDirHandleIVARS *const ivars = FSDH_IVARS(self);
+    struct dirent *sys_dir_entry = (struct dirent*)ivars->sys_dir_entry;
     if (!sys_dir_entry) { return false; }
 
     // If d_type is available, try to avoid a stat() call.  If it's not, or if
@@ -257,12 +266,12 @@ FSDH_entry_is_dir(FSDirHandle *self) {
     #endif
 
     struct stat stat_buf;
-    if (!self->fullpath) {
-        self->fullpath = CB_new(CB_Get_Size(self->dir) + 20);
+    if (!ivars->fullpath) {
+        ivars->fullpath = CB_new(CB_Get_Size(ivars->dir) + 20);
     }
-    CB_setf(self->fullpath, "%o%s%o", self->dir, CHY_DIR_SEP,
-            self->entry);
-    if (stat((char*)CB_Get_Ptr8(self->fullpath), &stat_buf) != -1) {
+    CB_setf(ivars->fullpath, "%o%s%o", ivars->dir, CHY_DIR_SEP,
+            ivars->entry);
+    if (stat((char*)CB_Get_Ptr8(ivars->fullpath), &stat_buf) != -1) {
         if (stat_buf.st_mode & S_IFDIR) { return true; }
     }
     return false;
@@ -270,7 +279,8 @@ FSDH_entry_is_dir(FSDirHandle *self) {
 
 bool
 FSDH_entry_is_symlink(FSDirHandle *self) {
-    struct dirent *sys_dir_entry = (struct dirent*)self->sys_dir_entry;
+    FSDirHandleIVARS *const ivars = FSDH_IVARS(self);
+    struct dirent *sys_dir_entry = (struct dirent*)ivars->sys_dir_entry;
     if (!sys_dir_entry) { return false; }
 
     #ifdef CHY_HAS_DIRENT_D_TYPE
@@ -278,12 +288,12 @@ FSDH_entry_is_symlink(FSDirHandle *self) {
     #else
     {
         struct stat stat_buf;
-        if (!self->fullpath) {
-            self->fullpath = CB_new(CB_Get_Size(self->dir) + 20);
+        if (!ivars->fullpath) {
+            ivars->fullpath = CB_new(CB_Get_Size(ivars->dir) + 20);
         }
-        CB_setf(self->fullpath, "%o%s%o", self->dir, CHY_DIR_SEP,
-                self->entry);
-        if (stat((char*)CB_Get_Ptr8(self->fullpath), &stat_buf) != -1) {
+        CB_setf(ivars->fullpath, "%o%s%o", ivars->dir, CHY_DIR_SEP,
+                ivars->entry);
+        if (stat((char*)CB_Get_Ptr8(ivars->fullpath), &stat_buf) != -1) {
             if (stat_buf.st_mode & S_IFLNK) { return true; }
         }
         return false;
@@ -293,13 +303,14 @@ FSDH_entry_is_symlink(FSDirHandle *self) {
 
 bool
 FSDH_close(FSDirHandle *self) {
-    if (self->fullpath) {
-        CB_Dec_RefCount(self->fullpath);
-        self->fullpath = NULL;
+    FSDirHandleIVARS *const ivars = FSDH_IVARS(self);
+    if (ivars->fullpath) {
+        CB_Dec_RefCount(ivars->fullpath);
+        ivars->fullpath = NULL;
     }
-    if (self->sys_dirhandle) {
-        DIR *sys_dirhandle = (DIR*)self->sys_dirhandle;
-        self->sys_dirhandle = NULL;
+    if (ivars->sys_dirhandle) {
+        DIR *sys_dirhandle = (DIR*)ivars->sys_dirhandle;
+        ivars->sys_dirhandle = NULL;
         if (closedir(sys_dirhandle) == -1) {
             Err_set_error(Err_new(CB_newf("Error closing dirhandle: %s",
                                           strerror(errno))));

http://git-wip-us.apache.org/repos/asf/lucy/blob/d04580a1/core/Lucy/Store/FSFileHandle.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Store/FSFileHandle.c b/core/Lucy/Store/FSFileHandle.c
index d9f9b41..4074a75 100644
--- a/core/Lucy/Store/FSFileHandle.c
+++ b/core/Lucy/Store/FSFileHandle.c
@@ -61,7 +61,8 @@ SI_posix_flags(uint32_t fh_flags) {
 // the requested length is 0, return NULL.  If an error occurs, return NULL
 // and set Err_error.
 static INLINE void*
-SI_map(FSFileHandle *self, int64_t offset, int64_t len);
+SI_map(FSFileHandle *self, FSFileHandleIVARS *ivars, int64_t offset,
+       int64_t len);
 
 // Release a memory mapped region assigned by SI_map.
 static INLINE bool
@@ -69,11 +70,12 @@ SI_unmap(FSFileHandle *self, char *ptr, int64_t len);
 
 // 32-bit or 64-bit inlined helpers for FSFH_window.
 static INLINE bool
-SI_window(FSFileHandle *self, FileWindow *window, int64_t offset, int64_t len);
+SI_window(FSFileHandle *self, FSFileHandleIVARS *ivars, FileWindow *window,
+          int64_t offset, int64_t len);
 
 // Architecture- and OS- specific initialization for a read-only FSFileHandle.
 static INLINE bool
-SI_init_read_only(FSFileHandle *self);
+SI_init_read_only(FSFileHandle *self, FSFileHandleIVARS *ivars);
 
 // Windows-specific routine needed for closing read-only handles.
 #ifdef CHY_HAS_WINDOWS_H
@@ -90,6 +92,7 @@ FSFH_open(const CharBuf *path, uint32_t flags) {
 FSFileHandle*
 FSFH_do_open(FSFileHandle *self, const CharBuf *path, uint32_t flags) {
     FH_do_open((FileHandle*)self, path, flags);
+    FSFileHandleIVARS *const ivars = FSFH_IVARS(self);
     if (!path || !CB_Get_Size(path)) {
         Err_set_error(Err_new(CB_newf("Missing required param 'path'")));
         CFISH_DECREF(self);
@@ -98,31 +101,31 @@ FSFH_do_open(FSFileHandle *self, const CharBuf *path, uint32_t flags) {
 
     // Attempt to open file.
     if (flags & FH_WRITE_ONLY) {
-        self->fd = open((char*)CB_Get_Ptr8(path), SI_posix_flags(flags), 0666);
-        if (self->fd == -1) {
-            self->fd = 0;
+        ivars->fd = open((char*)CB_Get_Ptr8(path), SI_posix_flags(flags), 0666);
+        if (ivars->fd == -1) {
+            ivars->fd = 0;
             Err_set_error(Err_new(CB_newf("Attempt to open '%o' failed: %s",
                                           path, strerror(errno))));
             CFISH_DECREF(self);
             return NULL;
         }
         if (flags & FH_EXCLUSIVE) {
-            self->len = 0;
+            ivars->len = 0;
         }
         else {
             // Derive length.
-            self->len = lseek64(self->fd, INT64_C(0), SEEK_END);
-            if (self->len == -1) {
+            ivars->len = lseek64(ivars->fd, INT64_C(0), SEEK_END);
+            if (ivars->len == -1) {
                 Err_set_error(Err_new(CB_newf("lseek64 on %o failed: %s",
-                                              self->path, strerror(errno))));
+                                              ivars->path, strerror(errno))));
                 CFISH_DECREF(self);
                 return NULL;
             }
             else {
-                int64_t check_val = lseek64(self->fd, INT64_C(0), SEEK_SET);
+                int64_t check_val = lseek64(ivars->fd, INT64_C(0), SEEK_SET);
                 if (check_val == -1) {
                     Err_set_error(Err_new(CB_newf("lseek64 on %o failed: %s",
-                                                  self->path, strerror(errno))));
+                                                  ivars->path, strerror(errno))));
                     CFISH_DECREF(self);
                     return NULL;
                 }
@@ -130,11 +133,11 @@ FSFH_do_open(FSFileHandle *self, const CharBuf *path, uint32_t flags) {
         }
     }
     else if (flags & FH_READ_ONLY) {
-        if (SI_init_read_only(self)) {
+        if (SI_init_read_only(self, ivars)) {
             // On 64-bit systems, map the whole file up-front.
-            if (IS_64_BIT && self->len) {
-                self->buf = (char*)SI_map(self, 0, self->len);
-                if (!self->buf) {
+            if (IS_64_BIT && ivars->len) {
+                ivars->buf = (char*)SI_map(self, ivars, 0, ivars->len);
+                if (!ivars->buf) {
                     // An error occurred during SI_map, which has set
                     // Err_error for us already.
                     CFISH_DECREF(self);
@@ -159,23 +162,25 @@ FSFH_do_open(FSFileHandle *self, const CharBuf *path, uint32_t flags) {
 
 bool
 FSFH_close(FSFileHandle *self) {
+    FSFileHandleIVARS *const ivars = FSFH_IVARS(self);
+
     // On 64-bit systems, cancel the whole-file mapping.
-    if (IS_64_BIT && (self->flags & FH_READ_ONLY) && self->buf != NULL) {
-        if (!SI_unmap(self, self->buf, self->len)) { return false; }
-        self->buf = NULL;
+    if (IS_64_BIT && (ivars->flags & FH_READ_ONLY) && ivars->buf != NULL) {
+        if (!SI_unmap(self, ivars->buf, ivars->len)) { return false; }
+        ivars->buf = NULL;
     }
 
     // Close system-specific handles.
-    if (self->fd) {
-        if (close(self->fd)) {
+    if (ivars->fd) {
+        if (close(ivars->fd)) {
             Err_set_error(Err_new(CB_newf("Failed to close file: %s",
                                           strerror(errno))));
             return false;
         }
-        self->fd  = 0;
+        ivars->fd  = 0;
     }
     #if (defined(CHY_HAS_WINDOWS_H) && !defined(CHY_HAS_SYS_MMAN_H))
-    if (self->win_fhandle) {
+    if (ivars->win_fhandle) {
         if (!SI_close_win_handles(self)) { return false; }
     }
     #endif
@@ -185,10 +190,12 @@ FSFH_close(FSFileHandle *self) {
 
 bool
 FSFH_write(FSFileHandle *self, const void *data, size_t len) {
+    FSFileHandleIVARS *const ivars = FSFH_IVARS(self);
+
     if (len) {
         // Write data, track file length, check for errors.
-        int64_t check_val = write(self->fd, data, len);
-        self->len += check_val;
+        int64_t check_val = write(ivars->fd, data, len);
+        ivars->len += check_val;
         if ((size_t)check_val != len) {
             if (check_val == -1) {
                 Err_set_error(Err_new(CB_newf("Error when writing %u64 bytes: %s",
@@ -207,14 +214,15 @@ FSFH_write(FSFileHandle *self, const void *data, size_t len) {
 
 int64_t
 FSFH_length(FSFileHandle *self) {
-    return self->len;
+    return FSFH_IVARS(self)->len;
 }
 
 bool
 FSFH_window(FSFileHandle *self, FileWindow *window, int64_t offset,
             int64_t len) {
+    FSFileHandleIVARS *const ivars = FSFH_IVARS(self);
     const int64_t end = offset + len;
-    if (!(self->flags & FH_READ_ONLY)) {
+    if (!(ivars->flags & FH_READ_ONLY)) {
         Err_set_error(Err_new(CB_newf("Can't read from write-only handle")));
         return false;
     }
@@ -223,13 +231,13 @@ FSFH_window(FSFileHandle *self, FileWindow *window, int64_t offset,
                                       offset)));
         return false;
     }
-    else if (end > self->len) {
+    else if (end > ivars->len) {
         Err_set_error(Err_new(CB_newf("Tried to read past EOF: offset %i64 + request %i64 > len %i64",
-                                      offset, len, self->len)));
+                                      offset, len, ivars->len)));
         return false;
     }
     else {
-        return SI_window(self, window, offset, len);
+        return SI_window(self, ivars, window, offset, len);
     }
 }
 
@@ -238,9 +246,10 @@ FSFH_window(FSFileHandle *self, FileWindow *window, int64_t offset,
 #if IS_64_BIT
 
 static INLINE bool
-SI_window(FSFileHandle *self, FileWindow *window, int64_t offset,
-          int64_t len) {
-    FileWindow_Set_Window(window, self->buf + offset, offset, len);
+SI_window(FSFileHandle *self, FSFileHandleIVARS *ivars, FileWindow *window,
+          int64_t offset, int64_t len) {
+    UNUSED_VAR(self);
+    FileWindow_Set_Window(window, ivars->buf + offset, offset, len);
     return true;
 }
 
@@ -253,9 +262,10 @@ FSFH_release_window(FSFileHandle *self, FileWindow *window) {
 
 bool
 FSFH_read(FSFileHandle *self, char *dest, int64_t offset, size_t len) {
+    FSFileHandleIVARS *const ivars = FSFH_IVARS(self);
     const int64_t end = offset + len;
 
-    if (self->flags & FH_WRITE_ONLY) {
+    if (ivars->flags & FH_WRITE_ONLY) {
         Err_set_error(Err_new(CB_newf("Can't read from write-only filehandle")));
         return false;
     }
@@ -264,12 +274,12 @@ FSFH_read(FSFileHandle *self, char *dest, int64_t offset, size_t len) {
                                       offset)));
         return false;
     }
-    else if (end > self->len) {
+    else if (end > ivars->len) {
         Err_set_error(Err_new(CB_newf("Tried to read past EOF: offset %i64 + request %u64 > len %i64",
-                                      offset, (uint64_t)len, self->len)));
+                                      offset, (uint64_t)len, ivars->len)));
         return false;
     }
-    memcpy(dest, self->buf + offset, len);
+    memcpy(dest, ivars->buf + offset, len);
     return true;
 }
 
@@ -278,18 +288,19 @@ FSFH_read(FSFileHandle *self, char *dest, int64_t offset, size_t len) {
 #else
 
 static INLINE bool
-SI_window(FSFileHandle *self, FileWindow *window, int64_t offset,
-          int64_t len) {
+SI_window(FSFileHandle *self, FSFileHandleIVARS *ivars, FileWindow *window,
+          int64_t offset, int64_t len) {
     // Release the previously mmap'd region, if any.
     FSFH_release_window(self, window);
 
     // Start map on a page boundary.  Ensure that the window is at
     // least wide enough to view all the data spec'd in the original
     // request.
-    const int64_t remainder       = offset % self->page_size;
+    const int64_t remainder       = offset % ivars->page_size;
     const int64_t adjusted_offset = offset - remainder;
     const int64_t adjusted_len    = len + remainder;
-    char *const buf = (char*)SI_map(self, adjusted_offset, adjusted_len);
+    char *const buf
+        = (char*)SI_map(self, ivars, adjusted_offset, adjusted_len);
     if (len && buf == NULL) {
         return false;
     }
@@ -314,38 +325,40 @@ FSFH_release_window(FSFileHandle *self, FileWindow *window) {
 #ifdef CHY_HAS_SYS_MMAN_H
 
 static INLINE bool
-SI_init_read_only(FSFileHandle *self) {
+SI_init_read_only(FSFileHandle *self, FSFileHandleIVARS *ivars) {
+    UNUSED_VAR(self);
+
     // Open.
-    self->fd = open((char*)CB_Get_Ptr8(self->path),
-                    SI_posix_flags(self->flags), 0666);
-    if (self->fd == -1) {
-        self->fd = 0;
-        Err_set_error(Err_new(CB_newf("Can't open '%o': %s", self->path,
+    ivars->fd = open((char*)CB_Get_Ptr8(ivars->path),
+                    SI_posix_flags(ivars->flags), 0666);
+    if (ivars->fd == -1) {
+        ivars->fd = 0;
+        Err_set_error(Err_new(CB_newf("Can't open '%o': %s", ivars->path,
                                       strerror(errno))));
         return false;
     }
 
     // Derive len.
-    self->len = lseek64(self->fd, INT64_C(0), SEEK_END);
-    if (self->len == -1) {
-        Err_set_error(Err_new(CB_newf("lseek64 on %o failed: %s", self->path,
+    ivars->len = lseek64(ivars->fd, INT64_C(0), SEEK_END);
+    if (ivars->len == -1) {
+        Err_set_error(Err_new(CB_newf("lseek64 on %o failed: %s", ivars->path,
                                       strerror(errno))));
         return false;
     }
     else {
-        int64_t check_val = lseek64(self->fd, INT64_C(0), SEEK_SET);
+        int64_t check_val = lseek64(ivars->fd, INT64_C(0), SEEK_SET);
         if (check_val == -1) {
             Err_set_error(Err_new(CB_newf("lseek64 on %o failed: %s",
-                                          self->path, strerror(errno))));
+                                          ivars->path, strerror(errno))));
             return false;
         }
     }
 
     // Get system page size.
 #if defined(_SC_PAGESIZE)
-    self->page_size = sysconf(_SC_PAGESIZE);
+    ivars->page_size = sysconf(_SC_PAGESIZE);
 #elif defined(_SC_PAGE_SIZE)
-    self->page_size = sysconf(_SC_PAGE_SIZE);
+    ivars->page_size = sysconf(_SC_PAGE_SIZE);
 #else
     #error "Can't determine system memory page size"
 #endif
@@ -354,17 +367,19 @@ SI_init_read_only(FSFileHandle *self) {
 }
 
 static INLINE void*
-SI_map(FSFileHandle *self, int64_t offset, int64_t len) {
+SI_map(FSFileHandle *self, FSFileHandleIVARS *ivars, int64_t offset,
+       int64_t len) {
+    UNUSED_VAR(self);
     void *buf = NULL;
 
     if (len) {
         // Read-only memory mapping.
-        buf = mmap(NULL, len, PROT_READ, MAP_SHARED, self->fd, offset);
+        buf = mmap(NULL, len, PROT_READ, MAP_SHARED, ivars->fd, offset);
         if (buf == (void*)(-1)) {
             Err_set_error(Err_new(CB_newf("mmap of offset %i64 and length %i64 (page size %i64) "
                                           "against '%o' failed: %s",
-                                          offset, len, self->page_size,
-                                          self->path, strerror(errno))));
+                                          offset, len, ivars->page_size,
+                                          ivars->path, strerror(errno))));
             return NULL;
         }
     }
@@ -377,7 +392,8 @@ SI_unmap(FSFileHandle *self, char *buf, int64_t len) {
     if (buf != NULL) {
         if (munmap(buf, len)) {
             Err_set_error(Err_new(CB_newf("Failed to munmap '%o': %s",
-                                          self->path, strerror(errno))));
+                                          FSFH_IVARS(self)->path,
+                                          strerror(errno))));
             return false;
         }
     }
@@ -387,6 +403,7 @@ SI_unmap(FSFileHandle *self, char *buf, int64_t len) {
 #if !IS_64_BIT
 bool
 FSFH_read(FSFileHandle *self, char *dest, int64_t offset, size_t len) {
+    FSFileHandleIVARS *const ivars = FSFH_IVARS(self);
     int64_t check_val;
 
     // Sanity check.
@@ -397,7 +414,7 @@ FSFH_read(FSFileHandle *self, char *dest, int64_t offset, size_t len) {
     }
 
     // Read.
-    check_val = pread64(self->fd, dest, len, offset);
+    check_val = pread64(ivars->fd, dest, len, offset);
     if (check_val != (int64_t)len) {
         if (check_val == -1) {
             Err_set_error(Err_new(CB_newf("Tried to read %u64 bytes, got %i64: %s",
@@ -419,16 +436,16 @@ FSFH_read(FSFileHandle *self, char *dest, int64_t offset, size_t len) {
 #elif defined(CHY_HAS_WINDOWS_H)
 
 static INLINE bool
-SI_init_read_only(FSFileHandle *self) {
-    char *filepath = (char*)CB_Get_Ptr8(self->path);
+SI_init_read_only(FSFileHandle *self, FSFileHandleIVARS *ivars) {
+    char *filepath = (char*)CB_Get_Ptr8(ivars->path);
     SYSTEM_INFO sys_info;
 
     // Get system page size.
     GetSystemInfo(&sys_info);
-    self->page_size = sys_info.dwAllocationGranularity;
+    ivars->page_size = sys_info.dwAllocationGranularity;
 
     // Open.
-    self->win_fhandle = CreateFile(
+    ivars->win_fhandle = CreateFile(
                             filepath,
                             GENERIC_READ,
                             FILE_SHARE_READ,
@@ -437,33 +454,33 @@ SI_init_read_only(FSFileHandle *self) {
                             FILE_ATTRIBUTE_READONLY | FILE_FLAG_OVERLAPPED,
                             NULL
                         );
-    if (self->win_fhandle == INVALID_HANDLE_VALUE) {
+    if (ivars->win_fhandle == INVALID_HANDLE_VALUE) {
         char *win_error = Err_win_error();
         Err_set_error(Err_new(CB_newf("CreateFile for %o failed: %s",
-                                      self->path, win_error)));
+                                      ivars->path, win_error)));
         FREEMEM(win_error);
         return false;
     }
 
     // Derive len.
     DWORD file_size_hi;
-    DWORD file_size_lo = GetFileSize(self->win_fhandle, &file_size_hi);
+    DWORD file_size_lo = GetFileSize(ivars->win_fhandle, &file_size_hi);
     if (file_size_lo == INVALID_FILE_SIZE && GetLastError() != NO_ERROR) {
         Err_set_error(Err_new(CB_newf("GetFileSize for %o failed",
-                                      self->path)));
+                                      ivars->path)));
         return false;
     }
-    self->len = ((uint64_t)file_size_hi << 32) | file_size_lo;
+    ivars->len = ((uint64_t)file_size_hi << 32) | file_size_lo;
 
     // Init mapping handle.
-    self->buf = NULL;
-    if (self->len) {
-        self->win_maphandle = CreateFileMapping(self->win_fhandle, NULL,
-                                                PAGE_READONLY, 0, 0, NULL);
-        if (self->win_maphandle == NULL) {
+    ivars->buf = NULL;
+    if (ivars->len) {
+        ivars->win_maphandle = CreateFileMapping(ivars->win_fhandle, NULL,
+                                                 PAGE_READONLY, 0, 0, NULL);
+        if (ivars->win_maphandle == NULL) {
             char *win_error = Err_win_error();
             Err_set_error(Err_new(CB_newf("CreateFileMapping for %o failed: %s",
-                                          self->path, win_error)));
+                                          ivars->path, win_error)));
             FREEMEM(win_error);
             return false;
         }
@@ -473,7 +490,8 @@ SI_init_read_only(FSFileHandle *self) {
 }
 
 static INLINE void*
-SI_map(FSFileHandle *self, int64_t offset, int64_t len) {
+SI_map(FSFileHandle *self, FSFileHandleIVARS *ivars, int64_t offset,
+       int64_t len) {
     void *buf = NULL;
 
     if (len) {
@@ -482,12 +500,12 @@ SI_map(FSFileHandle *self, int64_t offset, int64_t len) {
         DWORD file_offset_hi = offs >> 32;
         DWORD file_offset_lo = offs & 0xFFFFFFFF;
         size_t amount = (size_t)len;
-        buf = MapViewOfFile(self->win_maphandle, FILE_MAP_READ,
+        buf = MapViewOfFile(ivars->win_maphandle, FILE_MAP_READ,
                             file_offset_hi, file_offset_lo, amount);
         if (buf == NULL) {
             char *win_error = Err_win_error();
             Err_set_error(Err_new(CB_newf("MapViewOfFile for %o failed: %s",
-                                          self->path, win_error)));
+                                          ivars->path, win_error)));
             FREEMEM(win_error);
         }
     }
@@ -496,12 +514,13 @@ SI_map(FSFileHandle *self, int64_t offset, int64_t len) {
 }
 
 static INLINE bool
-SI_unmap(FSFileHandle *self, char *buf, int64_t len) {
+SI_unmap(FSFileHandle *self, char *ptr, int64_t len) {
     if (buf != NULL) {
         if (!UnmapViewOfFile(buf)) {
             char *win_error = Err_win_error();
             Err_set_error(Err_new(CB_newf("Failed to unmap '%o': %s",
-                                          self->path, win_error)));
+                                          FSFH_IVARS(self)->path,
+                                          win_error)));
             FREEMEM(win_error);
             return false;
         }
@@ -511,26 +530,27 @@ SI_unmap(FSFileHandle *self, char *buf, int64_t len) {
 
 static INLINE bool
 SI_close_win_handles(FSFileHandle *self) {
+    FSFileHandleIVARS *ivars = FSFH_IVARS(self);
     // Close both standard handle and mapping handle.
-    if (self->win_maphandle) {
-        if (!CloseHandle(self->win_maphandle)) {
+    if (ivars->win_maphandle) {
+        if (!CloseHandle(ivars->win_maphandle)) {
             char *win_error = Err_win_error();
             Err_set_error(Err_new(CB_newf("Failed to close file mapping handle: %s",
                                           win_error)));
             FREEMEM(win_error);
             return false;
         }
-        self->win_maphandle = NULL;
+        ivars->win_maphandle = NULL;
     }
-    if (self->win_fhandle) {
-        if (!CloseHandle(self->win_fhandle)) {
+    if (ivars->win_fhandle) {
+        if (!CloseHandle(ivars->win_fhandle)) {
             char *win_error = Err_win_error();
             Err_set_error(Err_new(CB_newf("Failed to close file handle: %s",
                                           win_error)));
             FREEMEM(win_error);
             return false;
         }
-        self->win_fhandle = NULL;
+        ivars->win_fhandle = NULL;
     }
 
     return true;
@@ -539,6 +559,7 @@ SI_close_win_handles(FSFileHandle *self) {
 #if !IS_64_BIT
 bool
 FSFH_read(FSFileHandle *self, char *dest, int64_t offset, size_t len) {
+    FSFileHandleIVARS *const ivars = FSFH_IVARS(self);
     BOOL check_val;
     DWORD got;
     OVERLAPPED read_op_state;
@@ -564,12 +585,12 @@ FSFH_read(FSFileHandle *self, char *dest, int64_t offset, size_t len) {
     }
 
     // Read.
-    check_val = ReadFile(self->win_fhandle, dest, len, &got, &read_op_state);
+    check_val = ReadFile(ivars->win_fhandle, dest, len, &got, &read_op_state);
     if (!check_val && GetLastError() == ERROR_IO_PENDING) {
         // Read has been queued by the OS and will soon complete.  Wait for
         // it, since this is a blocking IO call from the point of the rest of
         // the library.
-        check_val = GetOverlappedResult(self->win_fhandle, &read_op_state,
+        check_val = GetOverlappedResult(ivars->win_fhandle, &read_op_state,
                                         &got, TRUE);
     }
 

http://git-wip-us.apache.org/repos/asf/lucy/blob/d04580a1/core/Lucy/Store/FSFolder.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Store/FSFolder.c b/core/Lucy/Store/FSFolder.c
index ab6b15c..c80fff5 100644
--- a/core/Lucy/Store/FSFolder.c
+++ b/core/Lucy/Store/FSFolder.c
@@ -90,8 +90,9 @@ FSFolder_init(FSFolder *self, const CharBuf *path) {
 
 void
 FSFolder_initialize(FSFolder *self) {
-    if (!S_dir_ok(self->path)) {
-        if (!S_create_dir(self->path)) {
+    FSFolderIVARS *const ivars = FSFolder_IVARS(self);
+    if (!S_dir_ok(ivars->path)) {
+        if (!S_create_dir(ivars->path)) {
             RETHROW(INCREF(Err_get_error()));
         }
     }
@@ -99,7 +100,8 @@ FSFolder_initialize(FSFolder *self) {
 
 bool
 FSFolder_check(FSFolder *self) {
-    return S_dir_ok(self->path);
+    FSFolderIVARS *const ivars = FSFolder_IVARS(self);
+    return S_dir_ok(ivars->path);
 }
 
 FileHandle*
@@ -123,14 +125,16 @@ FSFolder_local_mkdir(FSFolder *self, const CharBuf *name) {
 
 DirHandle*
 FSFolder_local_open_dir(FSFolder *self) {
-    DirHandle *dh = (DirHandle*)FSDH_open(self->path);
+    FSFolderIVARS *const ivars = FSFolder_IVARS(self);
+    DirHandle *dh = (DirHandle*)FSDH_open(ivars->path);
     if (!dh) { ERR_ADD_FRAME(Err_get_error()); }
     return dh;
 }
 
 bool
 FSFolder_local_exists(FSFolder *self, const CharBuf *name) {
-    if (Hash_Fetch(self->entries, (Obj*)name)) {
+    FSFolderIVARS *const ivars = FSFolder_IVARS(self);
+    if (Hash_Fetch(ivars->entries, (Obj*)name)) {
         return true;
     }
     else if (!S_is_local_entry(name)) {
@@ -150,8 +154,10 @@ FSFolder_local_exists(FSFolder *self, const CharBuf *name) {
 
 bool
 FSFolder_local_is_directory(FSFolder *self, const CharBuf *name) {
+    FSFolderIVARS *const ivars = FSFolder_IVARS(self);
+
     // Check for a cached object, then fall back to a system call.
-    Obj *elem = Hash_Fetch(self->entries, (Obj*)name);
+    Obj *elem = Hash_Fetch(ivars->entries, (Obj*)name);
     if (elem && Obj_Is_A(elem, FOLDER)) {
         return true;
     }
@@ -191,6 +197,8 @@ FSFolder_hard_link(FSFolder *self, const CharBuf *from,
 
 bool
 FSFolder_local_delete(FSFolder *self, const CharBuf *name) {
+    FSFolderIVARS *const ivars = FSFolder_IVARS(self);
+
     CharBuf *fullpath = S_fullpath(self, name);
     char    *path_ptr = (char*)CB_Get_Ptr8(fullpath);
 #ifdef CHY_REMOVE_ZAPS_DIRS
@@ -198,18 +206,21 @@ FSFolder_local_delete(FSFolder *self, const CharBuf *name) {
 #else
     bool result = !rmdir(path_ptr) || !remove(path_ptr);
 #endif
-    DECREF(Hash_Delete(self->entries, (Obj*)name));
+    DECREF(Hash_Delete(ivars->entries, (Obj*)name));
     DECREF(fullpath);
     return result;
 }
 
 void
 FSFolder_close(FSFolder *self) {
-    Hash_Clear(self->entries);
+    FSFolderIVARS *const ivars = FSFolder_IVARS(self);
+    Hash_Clear(ivars->entries);
 }
 
 Folder*
 FSFolder_local_find_folder(FSFolder *self, const CharBuf *name) {
+    FSFolderIVARS *const ivars = FSFolder_IVARS(self);
+
     Folder *subfolder = NULL;
     if (!name || !CB_Get_Size(name)) {
         // No entity can be identified by NULL or empty string.
@@ -222,7 +233,7 @@ FSFolder_local_find_folder(FSFolder *self, const CharBuf *name) {
         // Don't allow access outside of the main dir.
         return NULL;
     }
-    else if (NULL != (subfolder = (Folder*)Hash_Fetch(self->entries, (Obj*)name))) {
+    else if (NULL != (subfolder = (Folder*)Hash_Fetch(ivars->entries, (Obj*)name))) {
         if (Folder_Is_A(subfolder, FOLDER)) {
             return subfolder;
         }
@@ -248,7 +259,7 @@ FSFolder_local_find_folder(FSFolder *self, const CharBuf *name) {
                 subfolder = (Folder*)cf_reader;
             }
         }
-        Hash_Store(self->entries, (Obj*)name, (Obj*)subfolder);
+        Hash_Store(ivars->entries, (Obj*)name, (Obj*)subfolder);
     }
     DECREF(fullpath);
 
@@ -257,7 +268,8 @@ FSFolder_local_find_folder(FSFolder *self, const CharBuf *name) {
 
 static CharBuf*
 S_fullpath(FSFolder *self, const CharBuf *path) {
-    CharBuf *fullpath = CB_newf("%o%s%o", self->path, DIR_SEP, path);
+    FSFolderIVARS *const ivars = FSFolder_IVARS(self);
+    CharBuf *fullpath = CB_newf("%o%s%o", ivars->path, DIR_SEP, path);
     if (DIR_SEP[0] != '/') {
         CB_Swap_Chars(fullpath, '/', DIR_SEP[0]);
     }

http://git-wip-us.apache.org/repos/asf/lucy/blob/d04580a1/core/Lucy/Store/FileHandle.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Store/FileHandle.c b/core/Lucy/Store/FileHandle.c
index 9b37809..4fcb235 100644
--- a/core/Lucy/Store/FileHandle.c
+++ b/core/Lucy/Store/FileHandle.c
@@ -23,8 +23,9 @@ int32_t FH_object_count = 0;
 
 FileHandle*
 FH_do_open(FileHandle *self, const CharBuf *path, uint32_t flags) {
-    self->path    = path ? CB_Clone(path) : CB_new(0);
-    self->flags   = flags;
+    FileHandleIVARS *const ivars = FH_IVARS(self);
+    ivars->path    = path ? CB_Clone(path) : CB_new(0);
+    ivars->flags   = flags;
 
     // Track number of live FileHandles released into the wild.
     FH_object_count++;
@@ -35,8 +36,9 @@ FH_do_open(FileHandle *self, const CharBuf *path, uint32_t flags) {
 
 void
 FH_destroy(FileHandle *self) {
+    FileHandleIVARS *const ivars = FH_IVARS(self);
     FH_Close(self);
-    DECREF(self->path);
+    DECREF(ivars->path);
     SUPER_DESTROY(self, FILEHANDLE);
 
     // Decrement count of FileHandle objects in existence.
@@ -52,12 +54,13 @@ FH_grow(FileHandle *self, int64_t length) {
 
 void
 FH_set_path(FileHandle *self, const CharBuf *path) {
-    CB_Mimic(self->path, (Obj*)path);
+    FileHandleIVARS *const ivars = FH_IVARS(self);
+    CB_Mimic(ivars->path, (Obj*)path);
 }
 
 CharBuf*
 FH_get_path(FileHandle *self) {
-    return self->path;
+    return FH_IVARS(self)->path;
 }
 
 

http://git-wip-us.apache.org/repos/asf/lucy/blob/d04580a1/core/Lucy/Store/FileWindow.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Store/FileWindow.c b/core/Lucy/Store/FileWindow.c
index 51b747e..067c6a8 100644
--- a/core/Lucy/Store/FileWindow.c
+++ b/core/Lucy/Store/FileWindow.c
@@ -32,21 +32,23 @@ FileWindow_init(FileWindow *self) {
 
 void
 FileWindow_set_offset(FileWindow *self, int64_t offset) {
-    if (self->buf != NULL) {
-        if (offset != self->offset) {
+    FileWindowIVARS *const ivars = FileWindow_IVARS(self);
+    if (ivars->buf != NULL) {
+        if (offset != ivars->offset) {
             THROW(ERR, "Can't set offset to %i64 instead of %i64 unless buf "
-                  "is NULL", offset, self->offset);
+                  "is NULL", offset, ivars->offset);
         }
     }
-    self->offset = offset;
+    ivars->offset = offset;
 }
 
 void
 FileWindow_set_window(FileWindow *self, char *buf, int64_t offset,
                       int64_t len) {
-    self->buf    = buf;
-    self->offset = offset;
-    self->len    = len;
+    FileWindowIVARS *const ivars = FileWindow_IVARS(self);
+    ivars->buf    = buf;
+    ivars->offset = offset;
+    ivars->len    = len;
 }
 
 

http://git-wip-us.apache.org/repos/asf/lucy/blob/d04580a1/core/Lucy/Store/Folder.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Store/Folder.c b/core/Lucy/Store/Folder.c
index 414a189..d87db4b 100644
--- a/core/Lucy/Store/Folder.c
+++ b/core/Lucy/Store/Folder.c
@@ -30,18 +30,20 @@
 
 Folder*
 Folder_init(Folder *self, const CharBuf *path) {
+    FolderIVARS *const ivars = Folder_IVARS(self);
+
     // Init.
-    self->entries = Hash_new(16);
+    ivars->entries = Hash_new(16);
 
     // Copy.
     if (path == NULL) {
-        self->path = CB_new_from_trusted_utf8("", 0);
+        ivars->path = CB_new_from_trusted_utf8("", 0);
     }
     else {
         // Copy path, strip trailing slash or equivalent.
-        self->path = CB_Clone(path);
-        if (CB_Ends_With_Str(self->path, DIR_SEP, strlen(DIR_SEP))) {
-            CB_Chop(self->path, 1);
+        ivars->path = CB_Clone(path);
+        if (CB_Ends_With_Str(ivars->path, DIR_SEP, strlen(DIR_SEP))) {
+            CB_Chop(ivars->path, 1);
         }
     }
 
@@ -51,8 +53,9 @@ Folder_init(Folder *self, const CharBuf *path) {
 
 void
 Folder_destroy(Folder *self) {
-    DECREF(self->path);
-    DECREF(self->entries);
+    FolderIVARS *const ivars = Folder_IVARS(self);
+    DECREF(ivars->path);
+    DECREF(ivars->entries);
     SUPER_DESTROY(self, FOLDER);
 }
 
@@ -382,13 +385,14 @@ Folder_slurp_file(Folder *self, const CharBuf *path) {
 
 CharBuf*
 Folder_get_path(Folder *self) {
-    return self->path;
+    return Folder_IVARS(self)->path;
 }
 
 void
 Folder_set_path(Folder *self, const CharBuf *path) {
-    DECREF(self->path);
-    self->path = CB_Clone(path);
+    FolderIVARS *const ivars = Folder_IVARS(self);
+    DECREF(ivars->path);
+    ivars->path = CB_Clone(path);
 }
 
 void
@@ -409,7 +413,8 @@ Folder_consolidate(Folder *self, const CharBuf *path) {
             ZombieCharBuf *name = IxFileNames_local_part(path, ZCB_BLANK());
             CompoundFileReader *cf_reader = CFReader_open(folder);
             if (!cf_reader) { RETHROW(INCREF(Err_get_error())); }
-            Hash_Store(enclosing_folder->entries, (Obj*)name,
+            Hash *entries = Folder_IVARS(enclosing_folder)->entries;
+            Hash_Store(entries, (Obj*)name,
                        (Obj*)cf_reader);
         }
     }

http://git-wip-us.apache.org/repos/asf/lucy/blob/d04580a1/core/Lucy/Store/InStream.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Store/InStream.c b/core/Lucy/Store/InStream.c
index 977d4a4..7727a11 100644
--- a/core/Lucy/Store/InStream.c
+++ b/core/Lucy/Store/InStream.c
@@ -35,7 +35,7 @@ SI_read_bytes(InStream *self, char* buf, size_t len);
 
 // Inlined version of InStream_Read_U8.
 static INLINE uint8_t
-SI_read_u8(InStream *self);
+SI_read_u8(InStream *self, InStreamIVARS *const ivars);
 
 // Ensure that the buffer contains exactly the specified amount of data.
 static void
@@ -55,22 +55,24 @@ InStream_open(Obj *file) {
 
 InStream*
 InStream_do_open(InStream *self, Obj *file) {
+    InStreamIVARS *const ivars = InStream_IVARS(self);
+
     // Init.
-    self->buf           = NULL;
-    self->limit         = NULL;
-    self->offset        = 0;
-    self->window        = FileWindow_new();
+    ivars->buf          = NULL;
+    ivars->limit        = NULL;
+    ivars->offset       = 0;
+    ivars->window       = FileWindow_new();
 
     // Obtain a FileHandle.
     if (Obj_Is_A(file, FILEHANDLE)) {
-        self->file_handle = (FileHandle*)INCREF(file);
+        ivars->file_handle = (FileHandle*)INCREF(file);
     }
     else if (Obj_Is_A(file, RAMFILE)) {
-        self->file_handle
+        ivars->file_handle
             = (FileHandle*)RAMFH_open(NULL, FH_READ_ONLY, (RAMFile*)file);
     }
     else if (Obj_Is_A(file, CHARBUF)) {
-        self->file_handle
+        ivars->file_handle
             = (FileHandle*)FSFH_open((CharBuf*)file, FH_READ_ONLY);
     }
     else {
@@ -79,16 +81,16 @@ InStream_do_open(InStream *self, Obj *file) {
         DECREF(self);
         return NULL;
     }
-    if (!self->file_handle) {
+    if (!ivars->file_handle) {
         ERR_ADD_FRAME(Err_get_error());
         DECREF(self);
         return NULL;
     }
 
     // Get length and filename from the FileHandle.
-    self->filename      = CB_Clone(FH_Get_Path(self->file_handle));
-    self->len           = FH_Length(self->file_handle);
-    if (self->len == -1) {
+    ivars->filename     = CB_Clone(FH_Get_Path(ivars->file_handle));
+    ivars->len          = FH_Length(ivars->file_handle);
+    if (ivars->len == -1) {
         ERR_ADD_FRAME(Err_get_error());
         DECREF(self);
         return NULL;
@@ -99,70 +101,79 @@ InStream_do_open(InStream *self, Obj *file) {
 
 void
 InStream_close(InStream *self) {
-    if (self->file_handle) {
-        FH_Release_Window(self->file_handle, self->window);
+    InStreamIVARS *const ivars = InStream_IVARS(self);
+    if (ivars->file_handle) {
+        FH_Release_Window(ivars->file_handle, ivars->window);
         // Note that we don't close the FileHandle, because it's probably
         // shared.
-        DECREF(self->file_handle);
-        self->file_handle = NULL;
+        DECREF(ivars->file_handle);
+        ivars->file_handle = NULL;
     }
 }
 
 void
 InStream_destroy(InStream *self) {
-    if (self->file_handle) {
+    InStreamIVARS *const ivars = InStream_IVARS(self);
+    if (ivars->file_handle) {
         InStream_Close(self);
     }
-    DECREF(self->filename);
-    DECREF(self->window);
+    DECREF(ivars->filename);
+    DECREF(ivars->window);
     SUPER_DESTROY(self, INSTREAM);
 }
 
 InStream*
 InStream_reopen(InStream *self, const CharBuf *filename, int64_t offset,
                 int64_t len) {
-    if (!self->file_handle) {
-        THROW(ERR, "Can't Reopen() closed InStream %o", self->filename);
+    InStreamIVARS *const ivars = InStream_IVARS(self);
+    if (!ivars->file_handle) {
+        THROW(ERR, "Can't Reopen() closed InStream %o", ivars->filename);
     }
-    if (offset + len > FH_Length(self->file_handle)) {
+    if (offset + len > FH_Length(ivars->file_handle)) {
         THROW(ERR, "Offset + length too large (%i64 + %i64 > %i64)",
-              offset, len, FH_Length(self->file_handle));
+              offset, len, FH_Length(ivars->file_handle));
     }
 
-    InStream *twin = (InStream*)VTable_Make_Obj(self->vtable);
-    InStream_do_open(twin, (Obj*)self->file_handle);
-    if (filename != NULL) { CB_Mimic(twin->filename, (Obj*)filename); }
-    twin->offset = offset;
-    twin->len    = len;
-    InStream_Seek(twin, 0);
+    VTable *vtable = InStream_Get_VTable(self);
+    InStream *other = (InStream*)VTable_Make_Obj(vtable);
+    InStreamIVARS *const ovars = InStream_IVARS(other);
+    InStream_do_open(other, (Obj*)ivars->file_handle);
+    if (filename != NULL) { CB_Mimic(ovars->filename, (Obj*)filename); }
+    ovars->offset = offset;
+    ovars->len    = len;
+    InStream_Seek(other, 0);
 
-    return twin;
+    return other;
 }
 
 InStream*
 InStream_clone(InStream *self) {
-    InStream *twin = (InStream*)VTable_Make_Obj(self->vtable);
-    InStream_do_open(twin, (Obj*)self->file_handle);
+    InStreamIVARS *const ivars = InStream_IVARS(self);
+    VTable *vtable = InStream_Get_VTable(self);
+    InStream *twin = (InStream*)VTable_Make_Obj(vtable);
+    InStream_do_open(twin, (Obj*)ivars->file_handle);
     InStream_Seek(twin, SI_tell(self));
     return twin;
 }
 
 CharBuf*
 InStream_get_filename(InStream *self) {
-    return self->filename;
+    return InStream_IVARS(self)->filename;
 }
 
 static int64_t
 S_refill(InStream *self) {
+    InStreamIVARS *const ivars = InStream_IVARS(self);
+
     // Determine the amount to request.
     const int64_t sub_file_pos = SI_tell(self);
-    const int64_t remaining    = self->len - sub_file_pos;
+    const int64_t remaining    = ivars->len - sub_file_pos;
     const int64_t amount       = remaining < IO_STREAM_BUF_SIZE
                                  ? remaining
                                  : IO_STREAM_BUF_SIZE;
     if (!remaining) {
         THROW(ERR, "Read past EOF of '%o' (offset: %i64 len: %i64)",
-              self->filename, self->offset, self->len);
+              ivars->filename, ivars->offset, ivars->len);
     }
 
     // Make the request.
@@ -178,31 +189,32 @@ InStream_refill(InStream *self) {
 
 static void
 S_fill(InStream *self, int64_t amount) {
-    FileWindow *const window     = self->window;
+    InStreamIVARS *const ivars     = InStream_IVARS(self);
+    FileWindow *const window       = ivars->window;
     const int64_t virtual_file_pos = SI_tell(self);
-    const int64_t real_file_pos    = virtual_file_pos + self->offset;
-    const int64_t remaining        = self->len - virtual_file_pos;
+    const int64_t real_file_pos    = virtual_file_pos + ivars->offset;
+    const int64_t remaining        = ivars->len - virtual_file_pos;
 
     // Throw an error if the requested amount would take us beyond EOF.
     if (amount > remaining) {
         THROW(ERR,  "Read past EOF of %o (pos: %u64 len: %u64 request: %u64)",
-              self->filename, virtual_file_pos, self->len, amount);
+              ivars->filename, virtual_file_pos, ivars->len, amount);
     }
 
     // Make the request.
-    if (FH_Window(self->file_handle, window, real_file_pos, amount)) {
+    if (FH_Window(ivars->file_handle, window, real_file_pos, amount)) {
         char *const window_limit = window->buf + window->len;
-        self->buf = window->buf
-                    - window->offset    // theoretical start of real file
-                    + self->offset      // top of virtual file
-                    + virtual_file_pos; // position within virtual file
-        self->limit = window_limit - self->buf > remaining
-                      ? self->buf + remaining
-                      : window_limit;
+        ivars->buf = window->buf
+                     - window->offset     // theoretical start of real file
+                     + ivars->offset      // top of virtual file
+                     + virtual_file_pos;  // position within virtual file
+        ivars->limit = window_limit - ivars->buf > remaining
+                       ? ivars->buf + remaining
+                       : window_limit;
     }
     else {
         Err *error = Err_get_error();
-        CB_catf(Err_Get_Mess(error), " (%o)", self->filename);
+        CB_catf(Err_Get_Mess(error), " (%o)", ivars->filename);
         RETHROW(INCREF(error));
     }
 }
@@ -214,40 +226,42 @@ InStream_fill(InStream *self, int64_t amount) {
 
 void
 InStream_seek(InStream *self, int64_t target) {
-    FileWindow *const window = self->window;
-    int64_t virtual_window_top = window->offset - self->offset;
+    InStreamIVARS *const ivars = InStream_IVARS(self);
+    FileWindow *const window = ivars->window;
+    int64_t virtual_window_top = window->offset - ivars->offset;
     int64_t virtual_window_end = virtual_window_top + window->len;
 
     if (target < 0) {
-        THROW(ERR, "Can't Seek '%o' to negative target %i64", self->filename,
+        THROW(ERR, "Can't Seek '%o' to negative target %i64", ivars->filename,
               target);
     }
     // Seek within window if possible.
     else if (target >= virtual_window_top
              && target <= virtual_window_end
             ) {
-        self->buf = window->buf - window->offset + self->offset + target;
+        ivars->buf = window->buf - window->offset + ivars->offset + target;
     }
-    else if (target > self->len) {
-        THROW(ERR, "Can't Seek '%o' past EOF (%i64 > %i64)", self->filename,
-              target, self->len);
+    else if (target > ivars->len) {
+        THROW(ERR, "Can't Seek '%o' past EOF (%i64 > %i64)", ivars->filename,
+              target, ivars->len);
     }
     else {
         // Target is outside window.  Set all buffer and limit variables to
         // NULL to trigger refill on the next read.  Store the file position
         // in the FileWindow's offset.
-        FH_Release_Window(self->file_handle, window);
-        self->buf   = NULL;
-        self->limit = NULL;
-        FileWindow_Set_Offset(window, self->offset + target);
+        FH_Release_Window(ivars->file_handle, window);
+        ivars->buf   = NULL;
+        ivars->limit = NULL;
+        FileWindow_Set_Offset(window, ivars->offset + target);
     }
 }
 
 static INLINE int64_t
 SI_tell(InStream *self) {
-    FileWindow *const window = self->window;
-    int64_t pos_in_buf = PTR_TO_I64(self->buf) - PTR_TO_I64(window->buf);
-    return pos_in_buf + window->offset - self->offset;
+    InStreamIVARS *const ivars = InStream_IVARS(self);
+    FileWindow *const window = ivars->window;
+    int64_t pos_in_buf = PTR_TO_I64(ivars->buf) - PTR_TO_I64(window->buf);
+    return pos_in_buf + window->offset - ivars->offset;
 }
 
 int64_t
@@ -257,12 +271,13 @@ InStream_tell(InStream *self) {
 
 int64_t
 InStream_length(InStream *self) {
-    return self->len;
+    return InStream_IVARS(self)->len;
 }
 
 char*
 InStream_buf(InStream *self, size_t request) {
-    const int64_t bytes_in_buf = PTR_TO_I64(self->limit) - PTR_TO_I64(self->buf);
+    InStreamIVARS *const ivars = InStream_IVARS(self);
+    const int64_t bytes_in_buf = PTR_TO_I64(ivars->limit) - PTR_TO_I64(ivars->buf);
 
     /* It's common for client code to overestimate how much is needed, because
      * the request has to figure in worst-case for compressed data.  However,
@@ -270,7 +285,7 @@ InStream_buf(InStream *self, size_t request) {
      * bytes, they really need 1 byte, and there's 1k in the buffer), we can
      * skip the following refill block. */
     if ((int64_t)request > bytes_in_buf) {
-        const int64_t remaining_in_file = self->len - SI_tell(self);
+        const int64_t remaining_in_file = ivars->len - SI_tell(self);
         int64_t amount = request;
 
         // Try to bump up small requests.
@@ -286,22 +301,23 @@ InStream_buf(InStream *self, size_t request) {
         }
     }
 
-    return self->buf;
+    return ivars->buf;
 }
 
 void
 InStream_advance_buf(InStream *self, char *buf) {
-    if (buf > self->limit) {
-        int64_t overrun = PTR_TO_I64(buf) - PTR_TO_I64(self->limit);
+    InStreamIVARS *const ivars = InStream_IVARS(self);
+    if (buf > ivars->limit) {
+        int64_t overrun = PTR_TO_I64(buf) - PTR_TO_I64(ivars->limit);
         THROW(ERR, "Supplied value is %i64 bytes beyond end of buffer",
               overrun);
     }
-    else if (buf < self->buf) {
-        int64_t underrun = PTR_TO_I64(self->buf) - PTR_TO_I64(buf);
+    else if (buf < ivars->buf) {
+        int64_t underrun = PTR_TO_I64(ivars->buf) - PTR_TO_I64(buf);
         THROW(ERR, "Can't Advance_Buf backwards: (underrun: %i64))", underrun);
     }
     else {
-        self->buf = buf;
+        ivars->buf = buf;
     }
 }
 
@@ -312,19 +328,20 @@ InStream_read_bytes(InStream *self, char* buf, size_t len) {
 
 static INLINE void
 SI_read_bytes(InStream *self, char* buf, size_t len) {
-    const int64_t available = PTR_TO_I64(self->limit) - PTR_TO_I64(self->buf);
+    InStreamIVARS *const ivars = InStream_IVARS(self);
+    const int64_t available = PTR_TO_I64(ivars->limit) - PTR_TO_I64(ivars->buf);
     if (available >= (int64_t)len) {
         // Request is entirely within buffer, so copy.
-        memcpy(buf, self->buf, len);
-        self->buf += len;
+        memcpy(buf, ivars->buf, len);
+        ivars->buf += len;
     }
     else {
         // Pass along whatever we've got in the buffer.
         if (available > 0) {
-            memcpy(buf, self->buf, (size_t)available);
+            memcpy(buf, ivars->buf, (size_t)available);
             buf += available;
             len -= (size_t)available;
-            self->buf += available;
+            ivars->buf += available;
         }
 
         if (len < IO_STREAM_BUF_SIZE) {
@@ -334,19 +351,19 @@ SI_read_bytes(InStream *self, char* buf, size_t len) {
                 int64_t orig_pos = SI_tell(self) - available;
                 int64_t orig_len = len + available;
                 THROW(ERR,  "Read past EOF of %o (pos: %i64 len: %i64 "
-                      "request: %i64)", self->filename, orig_pos,
-                      self->len, orig_len);
+                      "request: %i64)", ivars->filename, orig_pos,
+                      ivars->len, orig_len);
             }
-            memcpy(buf, self->buf, len);
-            self->buf += len;
+            memcpy(buf, ivars->buf, len);
+            ivars->buf += len;
         }
         else {
             // Too big to handle via the buffer, so resort to a brute-force
             // read.
             const int64_t sub_file_pos  = SI_tell(self);
-            const int64_t real_file_pos = sub_file_pos + self->offset;
+            const int64_t real_file_pos = sub_file_pos + ivars->offset;
             bool success
-                = FH_Read(self->file_handle, buf, real_file_pos, len);
+                = FH_Read(ivars->file_handle, buf, real_file_pos, len);
             if (!success) {
                 RETHROW(INCREF(Err_get_error()));
             }
@@ -357,18 +374,20 @@ SI_read_bytes(InStream *self, char* buf, size_t len) {
 
 int8_t
 InStream_read_i8(InStream *self) {
-    return (int8_t)SI_read_u8(self);
+    InStreamIVARS *const ivars = InStream_IVARS(self);
+    return (int8_t)SI_read_u8(self, ivars);
 }
 
 static INLINE uint8_t
-SI_read_u8(InStream *self) {
-    if (self->buf >= self->limit) { S_refill(self); }
-    return (uint8_t)(*self->buf++);
+SI_read_u8(InStream *self, InStreamIVARS *ivars) {
+    if (ivars->buf >= ivars->limit) { S_refill(self); }
+    return (uint8_t)(*ivars->buf++);
 }
 
 uint8_t
 InStream_read_u8(InStream *self) {
-    return SI_read_u8(self);
+    InStreamIVARS *const ivars = InStream_IVARS(self);
+    return SI_read_u8(self, ivars);
 }
 
 static INLINE uint32_t
@@ -433,9 +452,10 @@ InStream_read_f64(InStream *self) {
 
 uint32_t
 InStream_read_c32(InStream *self) {
+    InStreamIVARS *const ivars = InStream_IVARS(self);
     uint32_t retval = 0;
     while (1) {
-        const uint8_t ubyte = SI_read_u8(self);
+        const uint8_t ubyte = SI_read_u8(self, ivars);
         retval = (retval << 7) | (ubyte & 0x7f);
         if ((ubyte & 0x80) == 0) {
             break;
@@ -446,9 +466,10 @@ InStream_read_c32(InStream *self) {
 
 uint64_t
 InStream_read_c64(InStream *self) {
+    InStreamIVARS *const ivars = InStream_IVARS(self);
     uint64_t retval = 0;
     while (1) {
-        const uint8_t ubyte = SI_read_u8(self);
+        const uint8_t ubyte = SI_read_u8(self, ivars);
         retval = (retval << 7) | (ubyte & 0x7f);
         if ((ubyte & 0x80) == 0) {
             break;
@@ -459,9 +480,10 @@ InStream_read_c64(InStream *self) {
 
 int
 InStream_read_raw_c64(InStream *self, char *buf) {
+    InStreamIVARS *const ivars = InStream_IVARS(self);
     uint8_t *dest = (uint8_t*)buf;
     do {
-        *dest = SI_read_u8(self);
+        *dest = SI_read_u8(self, ivars);
     } while ((*dest++ & 0x80) != 0);
     return dest - (uint8_t*)buf;
 }

http://git-wip-us.apache.org/repos/asf/lucy/blob/d04580a1/core/Lucy/Store/Lock.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Store/Lock.c b/core/Lucy/Store/Lock.c
index 323b01d..6e8c68a 100644
--- a/core/Lucy/Store/Lock.c
+++ b/core/Lucy/Store/Lock.c
@@ -32,6 +32,8 @@
 Lock*
 Lock_init(Lock *self, Folder *folder, const CharBuf *name,
           const CharBuf *host, int32_t timeout, int32_t interval) {
+    LockIVARS *const ivars = Lock_IVARS(self);
+
     // Validate.
     if (interval <= 0) {
         DECREF(self);
@@ -52,51 +54,53 @@ Lock_init(Lock *self, Folder *folder, const CharBuf *name,
     }
 
     // Assign.
-    self->folder       = (Folder*)INCREF(folder);
-    self->timeout      = timeout;
-    self->name         = CB_Clone(name);
-    self->host         = CB_Clone(host);
-    self->interval     = interval;
+    ivars->folder       = (Folder*)INCREF(folder);
+    ivars->timeout      = timeout;
+    ivars->name         = CB_Clone(name);
+    ivars->host         = CB_Clone(host);
+    ivars->interval     = interval;
 
     // Derive.
-    self->lock_path = CB_newf("locks/%o.lock", name);
+    ivars->lock_path = CB_newf("locks/%o.lock", name);
 
     return self;
 }
 
 void
 Lock_destroy(Lock *self) {
-    DECREF(self->folder);
-    DECREF(self->host);
-    DECREF(self->name);
-    DECREF(self->lock_path);
+    LockIVARS *const ivars = Lock_IVARS(self);
+    DECREF(ivars->folder);
+    DECREF(ivars->host);
+    DECREF(ivars->name);
+    DECREF(ivars->lock_path);
     SUPER_DESTROY(self, LOCK);
 }
 
 CharBuf*
 Lock_get_name(Lock *self) {
-    return self->name;
+    return Lock_IVARS(self)->name;
 }
 
 CharBuf*
 Lock_get_lock_path(Lock *self) {
-    return self->lock_path;
+    return Lock_IVARS(self)->lock_path;
 }
 
 CharBuf*
 Lock_get_host(Lock *self) {
-    return self->host;
+    return Lock_IVARS(self)->host;
 }
 
 bool
 Lock_obtain(Lock *self) {
-    int32_t time_left = self->interval == 0 ? 0 : self->timeout;
+    LockIVARS *const ivars = Lock_IVARS(self);
+    int32_t time_left = ivars->interval == 0 ? 0 : ivars->timeout;
     bool locked = Lock_Request(self);
 
     while (!locked) {
-        time_left -= self->interval;
+        time_left -= ivars->interval;
         if (time_left <= 0) { break; }
-        Sleep_millisleep(self->interval);
+        Sleep_millisleep(ivars->interval);
         locked = Lock_Request(self);
     }
 
@@ -118,7 +122,8 @@ LFLock_init(LockFileLock *self, Folder *folder, const CharBuf *name,
             const CharBuf *host, int32_t timeout, int32_t interval) {
     int pid = PID_getpid();
     Lock_init((Lock*)self, folder, name, host, timeout, interval);
-    self->link_path = CB_newf("%o.%o.%i64", self->lock_path, host, pid);
+    LockFileLockIVARS *const ivars = LFLock_IVARS(self);
+    ivars->link_path = CB_newf("%o.%o.%i64", ivars->lock_path, host, pid);
     return self;
 }
 
@@ -129,26 +134,27 @@ LFLock_shared(LockFileLock *self) {
 
 bool
 LFLock_request(LockFileLock *self) {
+    LockFileLockIVARS *const ivars = LFLock_IVARS(self);
     Hash   *file_data;
     bool wrote_json;
     bool success = false;
     bool deletion_failed = false;
 
-    if (Folder_Exists(self->folder, self->lock_path)) {
+    if (Folder_Exists(ivars->folder, ivars->lock_path)) {
         Err_set_error((Err*)LockErr_new(CB_newf("Can't obtain lock: '%o' exists",
-                                                self->lock_path)));
+                                                ivars->lock_path)));
         return false;
     }
 
     // Create the "locks" subdirectory if necessary.
     CharBuf *lock_dir_name = (CharBuf*)ZCB_WRAP_STR("locks", 5);
-    if (!Folder_Exists(self->folder, lock_dir_name)) {
-        if (!Folder_MkDir(self->folder, lock_dir_name)) {
+    if (!Folder_Exists(ivars->folder, lock_dir_name)) {
+        if (!Folder_MkDir(ivars->folder, lock_dir_name)) {
             Err *mkdir_err = (Err*)CERTIFY(Err_get_error(), ERR);
             LockErr *err = LockErr_new(CB_newf("Can't create 'locks' directory: %o",
                                                Err_Get_Mess(mkdir_err)));
             // Maybe our attempt failed because another process succeeded.
-            if (Folder_Find_Folder(self->folder, lock_dir_name)) {
+            if (Folder_Find_Folder(ivars->folder, lock_dir_name)) {
                 DECREF(err);
             }
             else {
@@ -163,35 +169,35 @@ LFLock_request(LockFileLock *self) {
     file_data = Hash_new(3);
     Hash_Store_Str(file_data, "pid", 3,
                    (Obj*)CB_newf("%i32", (int32_t)PID_getpid()));
-    Hash_Store_Str(file_data, "host", 4, INCREF(self->host));
-    Hash_Store_Str(file_data, "name", 4, INCREF(self->name));
+    Hash_Store_Str(file_data, "host", 4, INCREF(ivars->host));
+    Hash_Store_Str(file_data, "name", 4, INCREF(ivars->name));
 
     // Write to a temporary file, then use the creation of a hard link to
     // ensure atomic but non-destructive creation of the lockfile with its
     // complete contents.
-    wrote_json = Json_spew_json((Obj*)file_data, self->folder, self->link_path);
+    wrote_json = Json_spew_json((Obj*)file_data, ivars->folder, ivars->link_path);
     if (wrote_json) {
-        success = Folder_Hard_Link(self->folder, self->link_path,
-                                   self->lock_path);
+        success = Folder_Hard_Link(ivars->folder, ivars->link_path,
+                                   ivars->lock_path);
         if (!success) {
             Err *hard_link_err = (Err*)CERTIFY(Err_get_error(), ERR);
             Err_set_error((Err*)LockErr_new(CB_newf("Failed to obtain lock at '%o': %o",
-                                                    self->lock_path,
+                                                    ivars->lock_path,
                                                     Err_Get_Mess(hard_link_err))));
         }
-        deletion_failed = !Folder_Delete(self->folder, self->link_path);
+        deletion_failed = !Folder_Delete(ivars->folder, ivars->link_path);
     }
     else {
         Err *spew_json_err = (Err*)CERTIFY(Err_get_error(), ERR);
         Err_set_error((Err*)LockErr_new(CB_newf("Failed to obtain lock at '%o': %o",
-                                                self->lock_path,
+                                                ivars->lock_path,
                                                 Err_Get_Mess(spew_json_err))));
     }
     DECREF(file_data);
 
     // Verify that our temporary file got zapped.
     if (wrote_json && deletion_failed) {
-        CharBuf *mess = MAKE_MESS("Failed to delete '%o'", self->link_path);
+        CharBuf *mess = MAKE_MESS("Failed to delete '%o'", ivars->link_path);
         Err_throw_mess(ERR, mess);
     }
 
@@ -200,25 +206,29 @@ LFLock_request(LockFileLock *self) {
 
 void
 LFLock_release(LockFileLock *self) {
-    if (Folder_Exists(self->folder, self->lock_path)) {
-        LFLock_Maybe_Delete_File(self, self->lock_path, true, false);
+    LockFileLockIVARS *const ivars = LFLock_IVARS(self);
+    if (Folder_Exists(ivars->folder, ivars->lock_path)) {
+        LFLock_Maybe_Delete_File(self, ivars->lock_path, true, false);
     }
 }
 
 bool
 LFLock_is_locked(LockFileLock *self) {
-    return Folder_Exists(self->folder, self->lock_path);
+    LockFileLockIVARS *const ivars = LFLock_IVARS(self);
+    return Folder_Exists(ivars->folder, ivars->lock_path);
 }
 
 void
 LFLock_clear_stale(LockFileLock *self) {
-    LFLock_Maybe_Delete_File(self, self->lock_path, false, true);
+    LockFileLockIVARS *const ivars = LFLock_IVARS(self);
+    LFLock_Maybe_Delete_File(self, ivars->lock_path, false, true);
 }
 
 bool
 LFLock_maybe_delete_file(LockFileLock *self, const CharBuf *path,
                          bool delete_mine, bool delete_other) {
-    Folder *folder  = self->folder;
+    LockFileLockIVARS *const ivars = LFLock_IVARS(self);
+    Folder *folder  = ivars->folder;
     bool    success = false;
     ZombieCharBuf *scratch = ZCB_WRAP(path);
 
@@ -228,7 +238,7 @@ LFLock_maybe_delete_file(LockFileLock *self, const CharBuf *path,
         return false;
     }
     ZCB_Nip(scratch, CB_Get_Size(lock_dir_name) + 1);
-    if (!ZCB_Starts_With(scratch, self->name)) {
+    if (!ZCB_Starts_With(scratch, ivars->name)) {
         return false;
     }
 
@@ -243,9 +253,9 @@ LFLock_maybe_delete_file(LockFileLock *self, const CharBuf *path,
 
             // Match hostname and lock name.
             if (host != NULL
-                && CB_Equals(host, (Obj*)self->host)
+                && CB_Equals(host, (Obj*)ivars->host)
                 && name != NULL
-                && CB_Equals(name, (Obj*)self->name)
+                && CB_Equals(name, (Obj*)ivars->name)
                 && pid_buf != NULL
                ) {
                 // Verify that pid is either mine or dead.
@@ -273,7 +283,8 @@ LFLock_maybe_delete_file(LockFileLock *self, const CharBuf *path,
 
 void
 LFLock_destroy(LockFileLock *self) {
-    DECREF(self->link_path);
+    LockFileLockIVARS *const ivars = LFLock_IVARS(self);
+    DECREF(ivars->link_path);
     SUPER_DESTROY(self, LOCKFILELOCK);
 }
 


Mime
View raw message