From 9262fc0ee141f6c46cbeb3a18dd38e6e2b9b444f Mon Sep 17 00:00:00 2001 From: Levi Neely <141506390+lneely@users.noreply.github.com> Date: Tue, 11 Mar 2025 22:01:25 +0100 Subject: [PATCH] psync_realloc removed --- pclsync/papi.c | 4 ++-- pclsync/pdeflate.c | 2 +- pclsync/pdiff.c | 2 +- pclsync/pfolder.c | 6 +++--- pclsync/plibs.c | 2 +- pclsync/plocalscan.c | 2 +- pclsync/psynclib.c | 11 +---------- pclsync/psynclib.h | 2 -- 8 files changed, 10 insertions(+), 21 deletions(-) diff --git a/pclsync/papi.c b/pclsync/papi.c index 2a9e1df..8532aaa 100644 --- a/pclsync/papi.c +++ b/pclsync/papi.c @@ -312,7 +312,7 @@ static binresult *do_parse_result(unsigned char **restrict indata, while (**indata != RPARAM_END) { if (cnt == alloc) { alloc *= 2; - arr = (binresult **)psync_realloc(arr, sizeof(binresult *) * alloc); + arr = (binresult **)realloc(arr, sizeof(binresult *) * alloc); } arr[cnt++] = do_parse_result(indata, odata, strings, nextstrid); } @@ -337,7 +337,7 @@ static binresult *do_parse_result(unsigned char **restrict indata, while (**indata != RPARAM_END) { if (cnt == alloc) { alloc *= 2; - arr = (struct _hashpair *)psync_realloc(arr, sizeof(struct _hashpair) * + arr = (struct _hashpair *)realloc(arr, sizeof(struct _hashpair) * alloc); } key = do_parse_result(indata, odata, strings, nextstrid); diff --git a/pclsync/pdeflate.c b/pclsync/pdeflate.c index 03e2dbe..047152b 100644 --- a/pclsync/pdeflate.c +++ b/pclsync/pdeflate.c @@ -168,7 +168,7 @@ static int psync_deflate_finish_flush_add_buffer(psync_deflate_t *def, } used += current; alloced *= 2; - buff = (unsigned char *)psync_realloc(buff, alloced); + buff = (unsigned char *)realloc(buff, alloced); current = alloced - used; } } diff --git a/pclsync/pdiff.c b/pclsync/pdiff.c index ca44cfb..3e9c6d3 100644 --- a/pclsync/pdiff.c +++ b/pclsync/pdiff.c @@ -2711,7 +2711,7 @@ static void psync_diff_refresh_fs_add_folder(psync_folderid_t folderid) { refresh_allocated *= 2; else refresh_allocated = 8; - refresh_folders = (psync_folderid_t *)psync_realloc( + refresh_folders = (psync_folderid_t *)realloc( refresh_folders, sizeof(psync_folderid_t) * refresh_allocated); } refresh_folders[refresh_last++] = folderid; diff --git a/pclsync/pfolder.c b/pclsync/pfolder.c index f8343a1..c63adc7 100644 --- a/pclsync/pfolder.c +++ b/pclsync/pfolder.c @@ -556,12 +556,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 *)psync_realloc( + list->entries = (pentry_t *)realloc( list->entries, sizeof(pentry_t) * list->entriesalloc); } while (list->nameoff + entry->namelen >= list->namealloc) { list->namealloc *= 2; - list->namebuff = (char *)psync_realloc(list->namebuff, list->namealloc); + list->namebuff = (char *)realloc(list->namebuff, list->namealloc); } memcpy(&list->entries[list->entriescnt++], entry, sizeof(pentry_t)); memcpy(list->namebuff + list->nameoff, entry->name, entry->namelen); @@ -835,7 +835,7 @@ psync_folder_list_t *pfolder_sync_folders(char *syncTypes) { while ((row = psync_sql_fetch_row(res))) { if (alloced == lastfolder) { alloced = (alloced + 32) * 2; - folders = (psync_tmp_folder_t *)psync_realloc( + folders = (psync_tmp_folder_t *)realloc( folders, sizeof(psync_tmp_folder_t) * alloced); } cstr = psync_get_lstring(row[2], &l); diff --git a/pclsync/plibs.c b/pclsync/plibs.c index f822d53..f686bec 100644 --- a/pclsync/plibs.c +++ b/pclsync/plibs.c @@ -1698,7 +1698,7 @@ psync_full_result_int *psync_sql_fetchall_int(psync_sql_res *res) { while ((code = sqlite3_step(res->stmt)) == SQLITE_ROW) { if (rows >= all) { all = 10 + all * 2; - data = (uint64_t *)psync_realloc(data, sizeof(uint64_t) * cols * all); + data = (uint64_t *)realloc(data, sizeof(uint64_t) * cols * all); } for (i = 0; i < cols; i++) data[off + i] = sqlite3_column_int64(res->stmt, i); diff --git a/pclsync/plocalscan.c b/pclsync/plocalscan.c index 796b228..371ba34 100644 --- a/pclsync/plocalscan.c +++ b/pclsync/plocalscan.c @@ -202,7 +202,7 @@ static void add_ignored_dir(const char *path) { ign_paths_alloc = 8; else ign_paths_alloc *= 2; - ignored_paths = (device_inode_t *)psync_realloc( + ignored_paths = (device_inode_t *)realloc( ignored_paths, sizeof(device_inode_t) * ign_paths_alloc); } ignored_paths[ign_paths_cnt].deviceid = pfile_stat_device_full(&st); diff --git a/pclsync/psynclib.c b/pclsync/psynclib.c index 002478a..b433f2f 100644 --- a/pclsync/psynclib.c +++ b/pclsync/psynclib.c @@ -165,15 +165,6 @@ PSYNC_NOINLINE void *psync_emergency_realloc(void *ptr, size_t size) { } } -void *psync_realloc(void *ptr, size_t size) { - void *ret; - ret = psync_real_realloc(ptr, size); - if (likely(ret)) - return ret; - else - return psync_emergency_realloc(ptr, size); -} - uint32_t psync_get_last_error() { return psync_error; } void psync_set_database_path(const char *databasepath) { @@ -1993,7 +1984,7 @@ psync_folderid_t *psync_crypto_folderids() { ret[l] = row[0]; if (++l == alloc) { alloc *= 2; - ret = (psync_folderid_t *)psync_realloc(ret, + ret = (psync_folderid_t *)realloc(ret, sizeof(psync_folderid_t) * alloc); } } diff --git a/pclsync/psynclib.h b/pclsync/psynclib.h index 112b02f..a749d00 100644 --- a/pclsync/psynclib.h +++ b/pclsync/psynclib.h @@ -514,8 +514,6 @@ typedef void (*psync_free_t)(void *); typedef void (*psync_generic_callback_t)(); -void *psync_realloc(void *ptr, size_t size); - /* Event callback is called every time a download/upload is started/finished, * quota is changed, folder is shared or similar. Look at the PEVENT_ constants * for a list of possible events.