Skip to content

Commit 34a7c2b

Browse files
committed
exmdb: simpler parameter types for {get,save}_change_indices EXRPCs
References: GXL-624
1 parent 9ef205a commit 34a7c2b

File tree

10 files changed

+115
-152
lines changed

10 files changed

+115
-152
lines changed

Makefile.am

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ tzd_files = data/AUS_Central.tzd data/AUS_Eastern.tzd data/Afghanistan.tzd data/
325325
tzd_files += data/Greenwich.tzd data/Haiti.tzd data/Hawaiian.tzd data/India.tzd data/Iran.tzd data/Israel.tzd data/Jordan.tzd data/Kaliningrad.tzd data/Korea.tzd data/Libya.tzd data/Line_Islands.tzd data/Lord_Howe.tzd data/Magadan.tzd data/Magallanes.tzd data/Marquesas.tzd data/Mauritius.tzd data/Middle_East.tzd data/Montevideo.tzd data/Morocco.tzd data/Mountain.tzd data/Mountain__Mexico_.tzd data/Myanmar.tzd data/N__Central_Asia.tzd data/Namibia.tzd data/Nepal.tzd data/New_Zealand.tzd data/Newfoundland.tzd data/Norfolk.tzd data/North_Asia.tzd data/North_Asia_East.tzd data/North_Korea.tzd data/Omsk.tzd data/Pacific.tzd data/Pacific_SA.tzd data/Pacific__Mexico_.tzd data/Pakistan.tzd data/Paraguay.tzd data/Qyzylorda.tzd data/Romance.tzd data/Russia_Time_Zone_10.tzd data/Russia_Time_Zone_11.tzd data/Russia_Time_Zone_3.tzd data/Russian.tzd data/SA_Eastern.tzd data/SA_Pacific.tzd data/SA_Western.tzd data/SE_Asia.tzd data/Saint_Pierre.tzd data/Sakhalin.tzd data/Samoa.tzd data/Sao_Tome.tzd
326326
tzd_files += data/Saratov.tzd data/Singapore.tzd data/South_Africa.tzd data/South_Sudan.tzd data/Sri_Lanka.tzd data/Sudan.tzd data/Syria.tzd data/Taipei.tzd data/Tasmania.tzd data/Tocantins.tzd data/Tokyo.tzd data/Tomsk.tzd data/Tonga.tzd data/Transbaikal.tzd data/Turkey.tzd data/Turks_And_Caicos.tzd data/US_Eastern.tzd data/US_Mountain.tzd data/UTC+12.tzd data/UTC+13.tzd data/UTC-02.tzd data/UTC-08.tzd data/UTC-09.tzd data/UTC-11.tzd data/UTC.tzd data/Ulaanbaatar.tzd data/Venezuela.tzd data/Vladivostok.tzd data/Volgograd.tzd data/W__Australia.tzd data/W__Central_Africa.tzd data/W__Europe.tzd data/W__Mongolia.tzd data/West_Asia.tzd data/West_Bank.tzd data/West_Pacific.tzd data/Yakutsk.tzd data/Yukon.tzd
327327
tzd_files += data/windowsZones.xml
328-
header_files = include/gromox/ab_tree.hpp include/gromox/arcfour.hpp include/gromox/archive.hpp include/gromox/atomic.hpp include/gromox/authmgr.hpp include/gromox/bounce_gen.hpp include/gromox/clock.hpp include/gromox/common_types.hpp include/gromox/config_file.hpp include/gromox/contexts_pool.hpp include/gromox/cookie_parser.hpp include/gromox/cryptoutil.hpp include/gromox/database.h include/gromox/database_mysql.hpp include/gromox/dbop.h include/gromox/dcerpc.hpp include/gromox/defs.h include/gromox/double_list.hpp include/gromox/dsn.hpp include/gromox/eid_array.hpp include/gromox/element_data.hpp include/gromox/exmdb_client.hpp include/gromox/exmdb_common_util.hpp include/gromox/exmdb_ext.hpp include/gromox/exmdb_idef.hpp include/gromox/exmdb_provider_client.hpp include/gromox/exmdb_rpc.hpp include/gromox/exmdb_server.hpp include/gromox/ext_buffer.hpp
328+
header_files = include/gromox/ab_tree.hpp include/gromox/algorithm.hpp include/gromox/arcfour.hpp include/gromox/archive.hpp include/gromox/atomic.hpp include/gromox/authmgr.hpp include/gromox/bounce_gen.hpp include/gromox/clock.hpp include/gromox/common_types.hpp include/gromox/config_file.hpp include/gromox/contexts_pool.hpp include/gromox/cookie_parser.hpp include/gromox/cryptoutil.hpp include/gromox/database.h include/gromox/database_mysql.hpp include/gromox/dbop.h include/gromox/dcerpc.hpp include/gromox/defs.h include/gromox/double_list.hpp include/gromox/dsn.hpp include/gromox/eid_array.hpp include/gromox/element_data.hpp include/gromox/exmdb_client.hpp include/gromox/exmdb_common_util.hpp include/gromox/exmdb_ext.hpp include/gromox/exmdb_idef.hpp include/gromox/exmdb_provider_client.hpp include/gromox/exmdb_rpc.hpp include/gromox/exmdb_server.hpp include/gromox/ext_buffer.hpp
329329
header_files += include/gromox/fileio.h include/gromox/flusher_common.h include/gromox/freebusy.hpp include/gromox/gab.hpp include/gromox/generic_connection.hpp include/gromox/hook_common.h include/gromox/hpm_common.h include/gromox/http.hpp include/gromox/ical.hpp include/gromox/icase.hpp include/gromox/json.hpp include/gromox/list_file.hpp include/gromox/lzxpress.hpp include/gromox/mail.hpp include/gromox/mail_func.hpp include/gromox/mapi_types.hpp include/gromox/mapidefs.h include/gromox/mapierr.hpp include/gromox/mapitags.hpp include/gromox/midb.hpp include/gromox/midb_agent.hpp include/gromox/mime.hpp include/gromox/mjson.hpp include/gromox/msgchg_grouping.hpp include/gromox/mysql_adaptor.hpp include/gromox/ndr.hpp include/gromox/ntlmssp.hpp include/gromox/oxcmail.hpp include/gromox/oxoabkt.hpp
330330
header_files += include/gromox/paths.h include/gromox/pcl.hpp include/gromox/plugin.hpp include/gromox/proc_common.h include/gromox/process.hpp include/gromox/proptag_array.hpp include/gromox/propval.hpp include/gromox/range_set.hpp include/gromox/resource_pool.hpp include/gromox/restriction.hpp include/gromox/rop_util.hpp include/gromox/rpc_types.hpp include/gromox/rule_actions.hpp include/gromox/safeint.hpp include/gromox/simple_tree.hpp include/gromox/sortorder_set.hpp include/gromox/stream.hpp include/gromox/svc_common.h include/gromox/svc_loader.hpp include/gromox/textmaps.hpp include/gromox/threads_pool.hpp include/gromox/tie.hpp include/gromox/tnef.hpp include/gromox/usercvt.hpp include/gromox/util.hpp include/gromox/vcard.hpp include/gromox/xarray2.hpp include/gromox/zcore_client.hpp include/gromox/zcore_rpc.hpp include/gromox/zcore_types.hpp include/gromox/zz_ndr_stack.hpp
331331
if ENABLE_PRIVATE_HEADERS

exch/emsmdb/common_util.cpp

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include <sys/stat.h>
2626
#include <sys/types.h>
2727
#include <vmime/message.hpp>
28+
#include <gromox/algorithm.hpp>
2829
#include <gromox/defs.h>
2930
#include <gromox/element_data.hpp>
3031
#include <gromox/ext_buffer.hpp>
@@ -1427,7 +1428,7 @@ void common_util_notify_receipt(const char *username, int type,
14271428
}
14281429

14291430
BOOL common_util_save_message_ics(logon_object *plogon,
1430-
uint64_t message_id, PROPTAG_ARRAY *pchanged_proptags)
1431+
uint64_t message_id, PROPTAG_ARRAY *pchanged_proptags) try
14311432
{
14321433
uint32_t tmp_index;
14331434
uint64_t change_num;
@@ -1461,34 +1462,31 @@ BOOL common_util_save_message_ics(logon_object *plogon,
14611462
if (pgpinfo == nullptr)
14621463
return FALSE;
14631464
}
1464-
/* memory format of PROPTAG_ARRAY is identical to LONG_ARRAY */
1465-
std::unique_ptr<PROPTAG_ARRAY, pta_delete> pindices(proptag_array_init());
1466-
if (pindices == nullptr)
1467-
return FALSE;
1468-
std::unique_ptr<PROPTAG_ARRAY, pta_delete> pungroup_proptags(proptag_array_init());
1469-
if (pungroup_proptags == nullptr)
1470-
return FALSE;
1471-
if (!pgpinfo->get_partial_index(PR_CHANGE_KEY, &tmp_index)) {
1472-
if (!proptag_array_append(pungroup_proptags.get(), PR_CHANGE_KEY))
1473-
return FALSE;
1465+
1466+
std::vector<uint32_t> groups;
1467+
std::vector<proptag_t> ugrp_tags;
1468+
if (pgpinfo->get_partial_index(PR_CHANGE_KEY, &tmp_index)) {
1469+
if (!contains(groups, tmp_index))
1470+
groups.emplace_back(tmp_index);
14741471
} else {
1475-
if (!proptag_array_append(pindices.get(), tmp_index))
1476-
return FALSE;
1472+
if (!contains(ugrp_tags, PR_CHANGE_KEY))
1473+
ugrp_tags.emplace_back(PR_CHANGE_KEY);
14771474
}
1478-
if (NULL != pchanged_proptags) {
1479-
for (const auto tag : *pchanged_proptags) {
1480-
if (!pgpinfo->get_partial_index(tag, &tmp_index)) {
1481-
if (!proptag_array_append(pungroup_proptags.get(), tag))
1482-
return FALSE;
1475+
if (pchanged_proptags != nullptr) {
1476+
for (const auto tag : *pchanged_proptags)
1477+
if (pgpinfo->get_partial_index(tag, &tmp_index)) {
1478+
if (!contains(groups, tmp_index))
1479+
groups.emplace_back(tmp_index);
14831480
} else {
1484-
if (!proptag_array_append(pindices.get(), tmp_index))
1485-
return FALSE;
1481+
if (!contains(ugrp_tags, tag))
1482+
ugrp_tags.emplace_back(tag);
14861483
}
1487-
}
1488-
14891484
}
14901485
return exmdb_client->save_change_indices(dir, message_id,
1491-
change_num, pindices.get(), pungroup_proptags.get());
1486+
change_num, groups, ugrp_tags);
1487+
} catch (const std::bad_alloc &) {
1488+
mlog(LV_ERR, "E-2904: ENOMEM");
1489+
return false;
14921490
}
14931491

14941492
static void common_util_set_dir(const char *dir)

exch/emsmdb/icsdownctx_object.cpp

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -613,8 +613,8 @@ static void icsdownctx_object_adjust_msgctnt(MESSAGE_CONTENT *pmsgctnt,
613613
static const property_groupinfo fake_gpinfo = {UINT32_MAX};
614614

615615
static BOOL icsdownctx_object_get_changepartial(icsdownctx_object *pctx,
616-
MESSAGE_CONTENT *pmsgctnt, uint32_t map_id, const INDEX_ARRAY *pindices,
617-
const PROPTAG_ARRAY *pproptags, MSGCHG_PARTIAL *pmsg)
616+
MESSAGE_CONTENT *pmsgctnt, uint32_t map_id, const std::vector<uint32_t> &group_list,
617+
const std::vector<proptag_t> &ugrp_tags, MSGCHG_PARTIAL *pmsg)
618618
{
619619
uint32_t index;
620620
PROPTAG_ARRAY *pchangetags;
@@ -637,8 +637,8 @@ static BOOL icsdownctx_object_get_changepartial(icsdownctx_object *pctx,
637637
return false;
638638
}
639639
}
640-
pmsg->count = pindices->count;
641-
if (pproptags->count != 0)
640+
pmsg->count = group_list.size();
641+
if (ugrp_tags.size() != 0)
642642
++pmsg->count;
643643
pmsg->pchanges = cu_alloc<CHANGE_PART>(pmsg->count);
644644
if (NULL == pmsg->pchanges) {
@@ -647,8 +647,8 @@ static BOOL icsdownctx_object_get_changepartial(icsdownctx_object *pctx,
647647
}
648648

649649
unsigned int i;
650-
for (i = 0; i < pindices->count; ++i) {
651-
index = pindices->pproptag[i];
650+
for (i = 0; i < group_list.size(); ++i) {
651+
index = group_list[i];
652652
pmsg->pchanges[i].index = index;
653653
pchangetags = pgpinfo->pgroups + index;
654654
auto &pl = pmsg->pchanges[i].proplist;
@@ -679,13 +679,13 @@ static BOOL icsdownctx_object_get_changepartial(icsdownctx_object *pctx,
679679
}
680680
pl.count = count;
681681
}
682-
if (pproptags->count == 0)
682+
if (ugrp_tags.empty())
683683
return TRUE;
684684
auto &pl = pmsg->pchanges[i].proplist;
685685
pmsg->pchanges[i].index = UINT32_MAX;
686-
pl.ppropval = cu_alloc<TAGGED_PROPVAL>(pproptags->count);
686+
pl.ppropval = cu_alloc<TAGGED_PROPVAL>(ugrp_tags.size());
687687
unsigned int count = 0;
688-
for (const auto proptag : *pproptags) {
688+
for (const auto proptag : ugrp_tags) {
689689
switch (proptag) {
690690
case PR_MESSAGE_RECIPIENTS:
691691
pl.ppropval[count].proptag = PR_MESSAGE_RECIPIENTS;
@@ -754,8 +754,6 @@ static BOOL icsdownctx_object_write_message_change(icsdownctx_object *pctx,
754754
BOOL b_full;
755755
void *pvalue;
756756
uint64_t last_cn;
757-
INDEX_ARRAY indices;
758-
PROPTAG_ARRAY proptags;
759757
PROGRESS_MESSAGE progmsg;
760758
TPROPVAL_ARRAY chgheader;
761759
MESSAGE_CONTENT *pmsgctnt;
@@ -899,6 +897,9 @@ static BOOL icsdownctx_object_write_message_change(icsdownctx_object *pctx,
899897
if (!(pctx->sync_flags & SYNC_IGNORE_SPECIFIED_ON_ASSOCIATED) ||
900898
cond1 || !progmsg.b_fai)
901899
icsdownctx_object_adjust_msgctnt(pmsgctnt, pctx->pproptags, cond1);
900+
901+
std::vector<uint32_t> groups;
902+
std::vector<proptag_t> ugrp_tags;
902903
if (!b_downloaded || progmsg.b_fai) {
903904
b_full = TRUE;
904905
} else {
@@ -913,17 +914,17 @@ static BOOL icsdownctx_object_write_message_change(icsdownctx_object *pctx,
913914
if (!pctx->pstate->pseen->get_repl_first_max(1, &last_cn))
914915
return false;
915916
if (!exmdb_client->get_change_indices(dir,
916-
message_id, last_cn, &indices, &proptags))
917+
message_id, last_cn, &groups, &ugrp_tags))
917918
return FALSE;
918-
if (0 == indices.count && 0 == proptags.count) {
919+
if (groups.empty() && ugrp_tags.empty()) {
919920
b_full = TRUE;
920921
} else {
921922
b_full = FALSE;
922923
(*ppartial_count) ++;
923924
}
924925
}
925926
if (!b_full && !icsdownctx_object_get_changepartial(pctx,
926-
pmsgctnt, map_id, &indices, &proptags, &msg_partial))
927+
pmsgctnt, map_id, groups, ugrp_tags, &msg_partial))
927928
return FALSE;
928929
}
929930
if (pctx->sync_flags & SYNC_PROGRESS_MODE &&

exch/emsmdb/message_object.cpp

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <memory>
1010
#include <vector>
1111
#include <libHX/string.h>
12+
#include <gromox/algorithm.hpp>
1213
#include <gromox/defs.h>
1314
#include <gromox/ext_buffer.hpp>
1415
#include <gromox/mapidefs.h>
@@ -329,7 +330,7 @@ static ec_error_t message_object_save2(message_object *pmessage, bool b_fai,
329330
return ecSuccess;
330331
}
331332

332-
ec_error_t message_object::save()
333+
ec_error_t message_object::save() try
333334
{
334335
auto pmessage = this;
335336
uint32_t result;
@@ -465,32 +466,28 @@ ec_error_t message_object::save()
465466
if (!exmdb_client->mark_modified(dir,
466467
pmessage->message_id))
467468
return ecRpcFailed;
468-
std::unique_ptr<INDEX_ARRAY, pta_delete> pindices(proptag_array_init());
469-
if (pindices == nullptr)
470-
return ecServerOOM;
471-
std::unique_ptr<PROPTAG_ARRAY, pta_delete> pungroup_proptags(proptag_array_init());
472-
if (pungroup_proptags == nullptr)
473-
return ecServerOOM;
469+
std::vector<uint32_t> groups;
470+
std::vector<proptag_t> ugrp_tags;
474471
/* always mark PR_MESSAGE_FLAGS as changed */
475472
if (!proptag_array_append(pmessage->pchanged_proptags, PR_MESSAGE_FLAGS))
476473
return ecRpcFailed;
477474
for (const auto tag : *pmessage->pchanged_proptags) {
478-
if (!pgpinfo->get_partial_index(tag, &tmp_index)) {
479-
if (!proptag_array_append(pungroup_proptags.get(), tag))
480-
return ecRpcFailed;
475+
if (pgpinfo->get_partial_index(tag, &tmp_index)) {
476+
if (!contains(groups, tmp_index))
477+
groups.emplace_back(tmp_index);
481478
} else {
482-
if (!proptag_array_append(pindices.get(), tmp_index))
483-
return ecRpcFailed;
479+
if (!contains(ugrp_tags, tag))
480+
ugrp_tags.emplace_back(tag);
484481
}
485482
}
486483
for (const auto tag : *pmessage->premoved_proptags) {
487484
if (!pgpinfo->get_partial_index(tag, &tmp_index))
488485
goto SAVE_FULL_CHANGE;
489-
else if (!proptag_array_append(pindices.get(), tmp_index))
490-
return ecRpcFailed;
486+
if (!contains(groups, tmp_index))
487+
groups.emplace_back(tmp_index);
491488
}
492-
if (!exmdb_client->save_change_indices(dir,
493-
pmessage->message_id, pmessage->change_num, pindices.get(), pungroup_proptags.get()))
489+
if (!exmdb_client->save_change_indices(dir, pmessage->message_id,
490+
pmessage->change_num, groups, ugrp_tags))
494491
return ecRpcFailed;
495492
proptag_array_clear(pmessage->pchanged_proptags);
496493
proptag_array_clear(pmessage->premoved_proptags);
@@ -500,10 +497,8 @@ ec_error_t message_object::save()
500497
SAVE_FULL_CHANGE:
501498
proptag_array_clear(pmessage->pchanged_proptags);
502499
proptag_array_clear(pmessage->premoved_proptags);
503-
INDEX_ARRAY tmp_indices{};
504500
if (!exmdb_client->save_change_indices(dir,
505-
pmessage->message_id, pmessage->change_num, &tmp_indices,
506-
static_cast<PROPTAG_ARRAY *>(&tmp_indices)))
501+
pmessage->message_id, pmessage->change_num, {}, {}))
507502
return ecRpcFailed;
508503
/* trigger the rule evaluation under public mode
509504
when the message is first saved to the folder */
@@ -513,6 +508,9 @@ ec_error_t message_object::save()
513508
pmessage->cpid, pmessage->folder_id,
514509
pmessage->message_id);
515510
return ecSuccess;
511+
} catch (const std::bad_alloc &) {
512+
mlog(LV_ERR, "E-2906: ENOMEM");
513+
return ecServerOOM;
516514
}
517515

518516
BOOL message_object::reload()

exch/exmdb/message.cpp

Lines changed: 16 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1143,21 +1143,21 @@ BOOL exmdb_server::set_pgm_id(const char *dir, uint64_t message_id, uint32_t map
11431143

11441144
/* if count of indices and ungroup_proptags are both 0 means full change */
11451145
BOOL exmdb_server::save_change_indices(const char *dir, uint64_t message_id,
1146-
uint64_t cn, const INDEX_ARRAY *pindices,
1147-
const PROPTAG_ARRAY *pungroup_proptags) try
1146+
uint64_t cn, const std::vector<uint32_t> &groups,
1147+
const std::vector<proptag_t> &ugrp_tags) try
11481148
{
11491149
EXT_PUSH ext_push;
11501150
char sql_string[128];
11511151
static constexpr size_t idbuff_size = 0x8000;
1152-
auto indices_buff = std::make_unique<uint8_t[]>(idbuff_size);
1153-
auto proptags_buff = std::make_unique<uint8_t[]>(idbuff_size);
1152+
auto grp_buf = std::make_unique<uint8_t[]>(idbuff_size);
1153+
auto utag_buf = std::make_unique<uint8_t[]>(idbuff_size);
11541154

11551155
auto pdb = db_engine_get_db(dir);
11561156
if (!pdb)
11571157
return FALSE;
11581158
/* Only one SQL operation, no transaction needed. */
11591159
auto mid_val = rop_util_get_gc_value(message_id);
1160-
if (0 == pindices->count && 0 == pungroup_proptags->count) {
1160+
if (groups.empty() && ugrp_tags.empty()) {
11611161
snprintf(sql_string, std::size(sql_string), "UPDATE messages SET "
11621162
"group_id=? WHERE message_id=%llu", LLU{mid_val});
11631163
auto pstmt = pdb->prep(sql_string);
@@ -1172,12 +1172,12 @@ BOOL exmdb_server::save_change_indices(const char *dir, uint64_t message_id,
11721172
return FALSE;
11731173
sqlite3_bind_int64(pstmt, 1, mid_val);
11741174
sqlite3_bind_int64(pstmt, 2, rop_util_get_gc_value(cn));
1175-
if (!ext_push.init(indices_buff.get(), idbuff_size, 0) ||
1176-
ext_push.p_proptag_a(*pindices) != pack_result::ok)
1175+
if (!ext_push.init(grp_buf.get(), idbuff_size, 0) ||
1176+
ext_push.p_proptag_a(groups) != pack_result::ok)
11771177
return false;
11781178
sqlite3_bind_blob(pstmt, 3, ext_push.m_udata, ext_push.m_offset, SQLITE_STATIC);
1179-
if (!ext_push.init(proptags_buff.get(), idbuff_size, 0) ||
1180-
ext_push.p_proptag_a(*pungroup_proptags) != pack_result::ok)
1179+
if (!ext_push.init(utag_buf.get(), idbuff_size, 0) ||
1180+
ext_push.p_proptag_a(ugrp_tags) != pack_result::ok)
11811181
return false;
11821182
sqlite3_bind_blob(pstmt, 4, ext_push.m_udata, ext_push.m_offset, SQLITE_STATIC);
11831183
return pstmt.step() == SQLITE_DONE ? TRUE : false;
@@ -1187,81 +1187,45 @@ BOOL exmdb_server::save_change_indices(const char *dir, uint64_t message_id,
11871187
}
11881188

11891189
/* if count of indices and ungroup_proptags are both 0 means full change */
1190-
BOOL exmdb_server::get_change_indices(const char *dir,
1191-
uint64_t message_id, uint64_t cn, INDEX_ARRAY *pindices,
1192-
PROPTAG_ARRAY *pungroup_proptags)
1190+
BOOL exmdb_server::get_change_indices(const char *dir, uint64_t message_id,
1191+
uint64_t cn, std::vector<uint32_t> *groups,
1192+
std::vector<gromox::proptag_t> *ugrp_tags)
11931193
{
11941194
EXT_PULL ext_pull;
1195-
INDEX_ARRAY tmp_indices;
1196-
PROPTAG_ARRAY tmp_proptags;
11971195

11981196
auto cn_val = rop_util_get_gc_value(cn);
11991197
auto pdb = db_engine_get_db(dir);
12001198
if (!pdb)
12011199
return FALSE;
12021200
/* Only one SQL operation, no transaction needed. */
12031201
auto mid_val = rop_util_get_gc_value(message_id);
1204-
std::unique_ptr<INDEX_ARRAY, pta_delete> ptmp_indices(proptag_array_init());
1205-
if (ptmp_indices == nullptr)
1206-
return FALSE;
1207-
std::unique_ptr<PROPTAG_ARRAY, pta_delete> ptmp_proptags(proptag_array_init());
1208-
if (ptmp_proptags == nullptr)
1209-
return FALSE;
12101202
char sql_string[128];
12111203
snprintf(sql_string, std::size(sql_string), "SELECT change_number,"
12121204
" indices, proptags FROM message_changes"
12131205
" WHERE message_id=%llu", LLU{mid_val});
12141206
auto pstmt = pdb->prep(sql_string);
12151207
if (pstmt == nullptr)
12161208
return FALSE;
1209+
groups->clear();
1210+
ugrp_tags->clear();
12171211
while (pstmt.step() == SQLITE_ROW) {
12181212
if (gx_sql_col_uint64(pstmt, 0) <= cn_val)
12191213
continue;
12201214
if (sqlite3_column_bytes(pstmt, 1) > 0) {
12211215
ext_pull.init(sqlite3_column_blob(pstmt, 1),
12221216
sqlite3_column_bytes(pstmt, 1),
12231217
common_util_alloc, 0);
1224-
if (ext_pull.g_proptag_a(&tmp_indices) != pack_result::ok)
1218+
if (ext_pull.g_proptag_a(groups) != pack_result::ok)
12251219
return FALSE;
1226-
for (unsigned int i = 0; i < tmp_indices.count; ++i)
1227-
if (!proptag_array_append(ptmp_indices.get(),
1228-
tmp_indices.pproptag[i]))
1229-
return FALSE;
12301220
}
12311221
if (sqlite3_column_bytes(pstmt, 2) > 0) {
12321222
ext_pull.init(sqlite3_column_blob(pstmt, 2),
12331223
sqlite3_column_bytes(pstmt, 2),
12341224
common_util_alloc, 0);
1235-
if (ext_pull.g_proptag_a(&tmp_proptags) != pack_result::ok)
1225+
if (ext_pull.g_proptag_a(ugrp_tags) != pack_result::ok)
12361226
return FALSE;
1237-
for (unsigned int i = 0; i < tmp_proptags.count; ++i)
1238-
if (!proptag_array_append(ptmp_proptags.get(),
1239-
tmp_proptags.pproptag[i]))
1240-
return FALSE;
12411227
}
12421228
}
1243-
pstmt.finalize();
1244-
pdb.reset();
1245-
pindices->count = ptmp_indices->count;
1246-
if (ptmp_indices->count > 0) {
1247-
pindices->pproptag = cu_alloc<uint32_t>(ptmp_indices->count);
1248-
if (pindices->pproptag == nullptr)
1249-
return FALSE;
1250-
memcpy(pindices->pproptag, ptmp_indices->pproptag,
1251-
sizeof(uint32_t)*ptmp_indices->count);
1252-
}
1253-
ptmp_indices.reset();
1254-
if (ptmp_proptags->count == 0) {
1255-
pungroup_proptags->count = 0;
1256-
pungroup_proptags->pproptag = NULL;
1257-
return TRUE;
1258-
}
1259-
pungroup_proptags->count = ptmp_proptags->count;
1260-
pungroup_proptags->pproptag = cu_alloc<uint32_t>(ptmp_proptags->count);
1261-
if (pungroup_proptags->pproptag == nullptr)
1262-
return FALSE;
1263-
memcpy(pungroup_proptags->pproptag, ptmp_proptags->pproptag,
1264-
sizeof(uint32_t)*ptmp_proptags->count);
12651229
return TRUE;
12661230
}
12671231

0 commit comments

Comments
 (0)