Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/msi/storages.c | 66 +++++++++++++++------------------------------ 1 file changed, 22 insertions(+), 44 deletions(-)
diff --git a/dlls/msi/storages.c b/dlls/msi/storages.c index 9e161c9e1b..76a0e2e03f 100644 --- a/dlls/msi/storages.c +++ b/dlls/msi/storages.c @@ -50,7 +50,7 @@ typedef struct tagMSISTORAGESVIEW { MSIVIEW view; MSIDATABASE *db; - STORAGE **storages; + STORAGE *storages; UINT max_storages; UINT num_rows; UINT row_size; @@ -61,7 +61,7 @@ static BOOL storages_set_table_size(MSISTORAGESVIEW *sv, UINT size) if (size >= sv->max_storages) { sv->max_storages *= 2; - sv->storages = msi_realloc(sv->storages, sv->max_storages * sizeof(STORAGE *)); + sv->storages = msi_realloc(sv->storages, sv->max_storages * sizeof(*sv->storages)); if (!sv->storages) return FALSE; } @@ -69,23 +69,6 @@ static BOOL storages_set_table_size(MSISTORAGESVIEW *sv, UINT size) return TRUE; }
-static STORAGE *create_storage(MSISTORAGESVIEW *sv, LPCWSTR name, IStorage *stg) -{ - STORAGE *storage; - - storage = msi_alloc(sizeof(STORAGE)); - if (!storage) - return NULL; - - storage->str_index = msi_add_string(sv->db->strings, name, -1, FALSE); - storage->storage = stg; - - if (storage->storage) - IStorage_AddRef(storage->storage); - - return storage; -} - static UINT STORAGES_fetch_int(struct tagMSIVIEW *view, UINT row, UINT col, UINT *val) { MSISTORAGESVIEW *sv = (MSISTORAGESVIEW *)view; @@ -98,7 +81,7 @@ static UINT STORAGES_fetch_int(struct tagMSIVIEW *view, UINT row, UINT col, UINT if (row >= sv->num_rows) return ERROR_NO_MORE_ITEMS;
- *val = sv->storages[row]->str_index; + *val = sv->storages[row].str_index;
return ERROR_SUCCESS; } @@ -173,7 +156,7 @@ done: static UINT STORAGES_set_row(struct tagMSIVIEW *view, UINT row, MSIRECORD *rec, UINT mask) { MSISTORAGESVIEW *sv = (MSISTORAGESVIEW *)view; - IStorage *stg, *substg = NULL; + IStorage *stg, *substg = NULL, *prev; IStream *stm; LPWSTR name = NULL; HRESULT hr; @@ -181,7 +164,7 @@ static UINT STORAGES_set_row(struct tagMSIVIEW *view, UINT row, MSIRECORD *rec,
TRACE("(%p, %p)\n", view, rec);
- if (row > sv->num_rows) + if (row >= sv->num_rows) return ERROR_FUNCTION_FAILED;
r = MSI_RecordGetIStream(rec, 2, &stm); @@ -218,9 +201,11 @@ static UINT STORAGES_set_row(struct tagMSIVIEW *view, UINT row, MSIRECORD *rec, goto done; }
- sv->storages[row] = create_storage(sv, name, stg); - if (!sv->storages[row]) - r = ERROR_FUNCTION_FAILED; + prev = sv->storages[row].storage; + sv->storages[row].str_index = msi_add_string(sv->db->strings, name, -1, FALSE); + IStorage_AddRef(stg); + sv->storages[row].storage = stg; + if (prev) IStorage_Release(prev);
done: msi_free(name); @@ -242,6 +227,8 @@ static UINT STORAGES_insert_row(struct tagMSIVIEW *view, MSIRECORD *rec, UINT ro if (row == -1) row = sv->num_rows - 1;
+ memset(&sv->storages[row], 0, sizeof(sv->storages[row])); + /* FIXME have to readjust rows */
return STORAGES_set_row(view, row, rec, 0); @@ -400,9 +387,8 @@ static UINT STORAGES_delete(struct tagMSIVIEW *view)
for (i = 0; i < sv->num_rows; i++) { - if (sv->storages[i]->storage) - IStorage_Release(sv->storages[i]->storage); - msi_free(sv->storages[i]); + if (sv->storages[i].storage) + IStorage_Release(sv->storages[i].storage); }
msi_free(sv->storages); @@ -436,7 +422,6 @@ static const MSIVIEWOPS storages_ops =
static INT add_storages_to_table(MSISTORAGESVIEW *sv) { - STORAGE *storage = NULL; IEnumSTATSTG *stgenum = NULL; STATSTG stat; HRESULT hr; @@ -447,7 +432,7 @@ static INT add_storages_to_table(MSISTORAGESVIEW *sv) return -1;
sv->max_storages = 1; - sv->storages = msi_alloc(sizeof(STORAGE *)); + sv->storages = msi_alloc(sizeof(*sv->storages)); if (!sv->storages) return -1;
@@ -466,26 +451,19 @@ static INT add_storages_to_table(MSISTORAGESVIEW *sv)
TRACE("enumerated storage %s\n", debugstr_w(stat.pwcsName));
- storage = create_storage(sv, stat.pwcsName, NULL); - if (!storage) - { - count = -1; - CoTaskMemFree(stat.pwcsName); - break; - } - - IStorage_OpenStorage(sv->db->storage, stat.pwcsName, NULL, - STGM_READ | STGM_SHARE_EXCLUSIVE, NULL, 0, - &storage->storage); - CoTaskMemFree(stat.pwcsName); - if (!storages_set_table_size(sv, ++count)) { count = -1; break; }
- sv->storages[count - 1] = storage; + sv->storages[count - 1].str_index = msi_add_string(sv->db->strings, stat.pwcsName, -1, FALSE); + sv->storages[count - 1].storage = NULL; + + IStorage_OpenStorage(sv->db->storage, stat.pwcsName, NULL, + STGM_READ | STGM_SHARE_EXCLUSIVE, NULL, 0, + &sv->storages[count - 1].storage); + CoTaskMemFree(stat.pwcsName); }
IEnumSTATSTG_Release(stgenum);