Replace all realloc() calls with pmem_realloc()
This commit is contained in:
parent
641709c03d
commit
4830df3cbd
|
|
@ -321,7 +321,7 @@ static binresult *do_parse_result(unsigned char **restrict indata,
|
|||
if (cnt == alloc) {
|
||||
binresult **tmp;
|
||||
alloc *= 2;
|
||||
tmp = (binresult **)realloc(arr, sizeof(binresult *) * alloc);
|
||||
tmp = (binresult **)pmem_realloc(PMEM_SUBSYS_API, arr, sizeof(binresult *) * alloc);
|
||||
if (!tmp) {
|
||||
pmem_free(PMEM_SUBSYS_API, arr);
|
||||
return NULL;
|
||||
|
|
@ -354,7 +354,7 @@ static binresult *do_parse_result(unsigned char **restrict indata,
|
|||
if (cnt == alloc) {
|
||||
struct _hashpair *tmp;
|
||||
alloc *= 2;
|
||||
tmp = (struct _hashpair *)realloc(arr, sizeof(struct _hashpair) *
|
||||
tmp = (struct _hashpair *)pmem_realloc(PMEM_SUBSYS_API, arr, sizeof(struct _hashpair) *
|
||||
alloc);
|
||||
if (!tmp) {
|
||||
pmem_free(PMEM_SUBSYS_API, arr);
|
||||
|
|
|
|||
|
|
@ -172,7 +172,7 @@ static int psync_deflate_finish_flush_add_buffer(psync_deflate_t *def,
|
|||
}
|
||||
used += current;
|
||||
alloced *= 2;
|
||||
buff = (unsigned char *)realloc(buff, alloced);
|
||||
buff = (unsigned char *)pmem_realloc(PMEM_SUBSYS_OTHER, buff, alloced);
|
||||
current = alloced - used;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2834,8 +2834,8 @@ static void psync_diff_refresh_fs_add_folder(psync_folderid_t folderid) {
|
|||
refresh_allocated *= 2;
|
||||
else
|
||||
refresh_allocated = 8;
|
||||
refresh_folders = (psync_folderid_t *)realloc(
|
||||
refresh_folders, sizeof(psync_folderid_t) * refresh_allocated);
|
||||
refresh_folders = (psync_folderid_t *)pmem_realloc(
|
||||
PMEM_SUBSYS_SYNC, refresh_folders, sizeof(psync_folderid_t) * refresh_allocated);
|
||||
}
|
||||
refresh_folders[refresh_last++] = folderid;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -568,12 +568,12 @@ static folder_list *folder_list_init() {
|
|||
static void folder_list_add(folder_list *list, pentry_t *entry) {
|
||||
if (list->entriescnt >= list->entriesalloc) {
|
||||
list->entriesalloc *= 2;
|
||||
list->entries = (pentry_t *)realloc(
|
||||
list->entries = (pentry_t *)pmem_realloc(PMEM_SUBSYS_OTHER,
|
||||
list->entries, sizeof(pentry_t) * list->entriesalloc);
|
||||
}
|
||||
while (list->nameoff + entry->namelen >= list->namealloc) {
|
||||
list->namealloc *= 2;
|
||||
list->namebuff = (char *)realloc(list->namebuff, list->namealloc);
|
||||
list->namebuff = (char *)pmem_realloc(PMEM_SUBSYS_OTHER, list->namebuff, list->namealloc);
|
||||
}
|
||||
memcpy(&list->entries[list->entriescnt++], entry, sizeof(pentry_t));
|
||||
memcpy(list->namebuff + list->nameoff, entry->name, entry->namelen);
|
||||
|
|
@ -847,7 +847,7 @@ psync_folder_list_t *pfolder_sync_folders(char *syncTypes) {
|
|||
while ((row = psql_fetch(res))) {
|
||||
if (alloced == lastfolder) {
|
||||
alloced = (alloced + 32) * 2;
|
||||
folders = (psync_tmp_folder_t *)realloc(
|
||||
folders = (psync_tmp_folder_t *)pmem_realloc(PMEM_SUBSYS_OTHER,
|
||||
folders, sizeof(psync_tmp_folder_t) * alloced);
|
||||
}
|
||||
cstr = psync_get_lstring(row[2], &l);
|
||||
|
|
|
|||
|
|
@ -198,7 +198,7 @@ static void add_ignored_dir(const char *path) {
|
|||
ign_paths_alloc = 8;
|
||||
else
|
||||
ign_paths_alloc *= 2;
|
||||
ignored_paths = (device_inode_t *)realloc(
|
||||
ignored_paths = (device_inode_t *)pmem_realloc(PMEM_SUBSYS_SYNC,
|
||||
ignored_paths, sizeof(device_inode_t) * ign_paths_alloc);
|
||||
}
|
||||
ignored_paths[ign_paths_cnt].deviceid = pfile_stat_device_full(&st);
|
||||
|
|
|
|||
|
|
@ -2680,7 +2680,7 @@ int psync_send_pdbg_logf(int thread, const char *file, const char *function,
|
|||
do {
|
||||
char *tmp;
|
||||
sz = l + 1;
|
||||
tmp = (char *)realloc(ret, sz);
|
||||
tmp = (char *)pmem_realloc(PMEM_SUBSYS_OTHER, ret, sz);
|
||||
if (!tmp) {
|
||||
pmem_free(PMEM_SUBSYS_OTHER, ret);
|
||||
return -1;
|
||||
|
|
|
|||
|
|
@ -780,7 +780,7 @@ psync_full_result_int *psql_fetchall_int(psync_sql_res *res) {
|
|||
while ((code = sqlite3_step(res->stmt)) == SQLITE_ROW) {
|
||||
if (rows >= all) {
|
||||
all = 10 + all * 2;
|
||||
data = (uint64_t *)realloc(data, sizeof(uint64_t) * cols * all);
|
||||
data = (uint64_t *)pmem_realloc(PMEM_SUBSYS_OTHER, data, sizeof(uint64_t) * cols * all);
|
||||
}
|
||||
for (i = 0; i < cols; i++)
|
||||
data[off + i] = sqlite3_column_int64(res->stmt, i);
|
||||
|
|
|
|||
|
|
@ -1772,7 +1772,7 @@ psync_folderid_t *psync_crypto_folderids() {
|
|||
ret[l] = row[0];
|
||||
if (++l == alloc) {
|
||||
alloc *= 2;
|
||||
ret = (psync_folderid_t *)realloc(ret,
|
||||
ret = (psync_folderid_t *)pmem_realloc(PMEM_SUBSYS_OTHER, ret,
|
||||
sizeof(psync_folderid_t) * alloc);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue