psync_malloc removed
This commit is contained in:
parent
58771bb524
commit
dea5073ae4
|
|
@ -308,7 +308,7 @@ static binresult *do_parse_result(unsigned char **restrict indata,
|
|||
arr = NULL;
|
||||
cnt = 0;
|
||||
alloc = 128;
|
||||
arr = (binresult **)psync_malloc(sizeof(binresult *) * alloc);
|
||||
arr = (binresult **)malloc(sizeof(binresult *) * alloc);
|
||||
while (**indata != RPARAM_END) {
|
||||
if (cnt == alloc) {
|
||||
alloc *= 2;
|
||||
|
|
@ -333,7 +333,7 @@ static binresult *do_parse_result(unsigned char **restrict indata,
|
|||
arr = NULL;
|
||||
cnt = 0;
|
||||
alloc = 32;
|
||||
arr = (struct _hashpair *)psync_malloc(sizeof(struct _hashpair) * alloc);
|
||||
arr = (struct _hashpair *)malloc(sizeof(struct _hashpair) * alloc);
|
||||
while (**indata != RPARAM_END) {
|
||||
if (cnt == alloc) {
|
||||
alloc *= 2;
|
||||
|
|
@ -395,7 +395,7 @@ binresult *papi_result(psock_t *sock) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
data = (unsigned char *)psync_malloc(ressize);
|
||||
data = (unsigned char *)malloc(ressize);
|
||||
|
||||
if (unlikely_log(psock_readall(sock, data, ressize) != ressize)) {
|
||||
free(data);
|
||||
|
|
@ -415,7 +415,7 @@ binresult *papi_result_thread(psock_t *sock) {
|
|||
if (unlikely_log(psock_readall_thread(
|
||||
sock, &ressize, sizeof(uint32_t)) != sizeof(uint32_t)))
|
||||
return NULL;
|
||||
data = (unsigned char *)psync_malloc(ressize);
|
||||
data = (unsigned char *)malloc(ressize);
|
||||
if (unlikely_log(psock_readall_thread(sock, data, ressize) !=
|
||||
ressize)) {
|
||||
free(data);
|
||||
|
|
@ -458,7 +458,7 @@ again:
|
|||
reader->state = 1;
|
||||
reader->bytesread = 0;
|
||||
reader->bytestoread = reader->respsize;
|
||||
reader->data = (unsigned char *)psync_malloc(reader->respsize);
|
||||
reader->data = (unsigned char *)malloc(reader->respsize);
|
||||
goto again;
|
||||
} else {
|
||||
assert(reader->state == 1);
|
||||
|
|
@ -496,7 +496,7 @@ unsigned char *papi_prepare(const char *command, size_t cmdlen,
|
|||
}
|
||||
if (unlikely_log(plen > 0xffff))
|
||||
return NULL;
|
||||
sdata = data = (unsigned char *)psync_malloc(plen + 2 + additionalalloc);
|
||||
sdata = data = (unsigned char *)malloc(plen + 2 + additionalalloc);
|
||||
memcpy(data, &plen, 2);
|
||||
data += 2;
|
||||
if (datalen != -1) {
|
||||
|
|
|
|||
|
|
@ -102,12 +102,12 @@ int do_psync_account_stopshare(psync_shareid_t usershareids[], int nusershareid,
|
|||
if (unlikely(numparam == 1))
|
||||
return -3;
|
||||
|
||||
t = (binparam *)psync_malloc(numparam * sizeof(binparam));
|
||||
t = (binparam *)malloc(numparam * sizeof(binparam));
|
||||
|
||||
init_param_str(t, "auth", psync_my_auth);
|
||||
|
||||
if (nusershareid) {
|
||||
ids1 = (char *)psync_malloc(nusershareid * FOLDERID_ENTRY_SIZE);
|
||||
ids1 = (char *)malloc(nusershareid * FOLDERID_ENTRY_SIZE);
|
||||
idsp = ids1;
|
||||
for (i = 0; i < nusershareid; ++i) {
|
||||
k = sprintf(idsp, "%lld", (long long)usershareids[i]);
|
||||
|
|
@ -123,7 +123,7 @@ int do_psync_account_stopshare(psync_shareid_t usershareids[], int nusershareid,
|
|||
}
|
||||
|
||||
if (nteamshareid) {
|
||||
ids2 = (char *)psync_malloc(nteamshareid * FOLDERID_ENTRY_SIZE);
|
||||
ids2 = (char *)malloc(nteamshareid * FOLDERID_ENTRY_SIZE);
|
||||
idsp = ids2;
|
||||
for (i = 0; i < nteamshareid; ++i) {
|
||||
k = sprintf(idsp, "%lld", (long long)teamshareids[i]);
|
||||
|
|
@ -208,14 +208,14 @@ int do_psync_account_modifyshare(psync_shareid_t usrshrids[], uint32_t uperms[],
|
|||
if (unlikely(numparam == 1))
|
||||
return -3;
|
||||
|
||||
t = (binparam *)psync_malloc(numparam * sizeof(binparam));
|
||||
t = (binparam *)malloc(numparam * sizeof(binparam));
|
||||
|
||||
init_param_str(t, "auth", psync_my_auth);
|
||||
|
||||
if (nushid) {
|
||||
ids1 = (char *)psync_malloc(nushid * FOLDERID_ENTRY_SIZE);
|
||||
ids1 = (char *)malloc(nushid * FOLDERID_ENTRY_SIZE);
|
||||
idsp = ids1;
|
||||
perms1 = (char *)psync_malloc(nushid * FOLDERID_ENTRY_SIZE);
|
||||
perms1 = (char *)malloc(nushid * FOLDERID_ENTRY_SIZE);
|
||||
permsp = perms1;
|
||||
for (i = 0; i < nushid; ++i) {
|
||||
k = sprintf(idsp, "%lld", (long long)usrshrids[i]);
|
||||
|
|
@ -240,9 +240,9 @@ int do_psync_account_modifyshare(psync_shareid_t usrshrids[], uint32_t uperms[],
|
|||
}
|
||||
|
||||
if (ntmshid) {
|
||||
ids2 = (char *)psync_malloc(ntmshid * FOLDERID_ENTRY_SIZE);
|
||||
ids2 = (char *)malloc(ntmshid * FOLDERID_ENTRY_SIZE);
|
||||
idsp = ids2;
|
||||
perms2 = (char *)psync_malloc(ntmshid * FOLDERID_ENTRY_SIZE);
|
||||
perms2 = (char *)malloc(ntmshid * FOLDERID_ENTRY_SIZE);
|
||||
permsp = perms2;
|
||||
|
||||
for (i = 0; i < ntmshid; ++i) {
|
||||
|
|
@ -330,7 +330,7 @@ void get_ba_member_email(uint64_t userid, char **email /*OUT*/,
|
|||
psync_sql_bind_uint(res, 1, userid);
|
||||
if ((row = psync_sql_fetch_row(res))) {
|
||||
cstr = psync_get_lstring(row[0], length);
|
||||
*email = (char *)psync_malloc(*length);
|
||||
*email = (char *)malloc(*length);
|
||||
memcpy(*email, cstr, *length);
|
||||
psync_sql_free_result(res);
|
||||
return;
|
||||
|
|
@ -396,7 +396,7 @@ void get_ba_team_name(uint64_t teamid, char **name /*OUT*/,
|
|||
psync_sql_bind_uint(res, 1, teamid);
|
||||
if ((row = psync_sql_fetch_row(res))) {
|
||||
cstr = psync_get_lstring(row[0], length);
|
||||
*name = (char *)psync_malloc(*length);
|
||||
*name = (char *)malloc(*length);
|
||||
memcpy(*name, cstr, *length);
|
||||
psync_sql_free_result(res);
|
||||
return;
|
||||
|
|
@ -741,7 +741,7 @@ static psync_folderid_t create_index_folder(const char *path) {
|
|||
while (ind < 100) {
|
||||
bufflen = strlen(path) + 1 /*zero char*/ + 3 /*parenthesis*/ +
|
||||
3 /*up to 3 digit index*/;
|
||||
buff = (char *)psync_malloc(bufflen);
|
||||
buff = (char *)malloc(bufflen);
|
||||
snprintf(buff, bufflen - 1, "%s (%d)", path, ind);
|
||||
if (psync_create_remote_folder_by_path(buff, &err) != 0)
|
||||
debug(D_NOTICE, "Unable to create folder %s error is %s.", buff, err);
|
||||
|
|
|
|||
|
|
@ -164,7 +164,7 @@ void pcache_add(const char *key, void *ptr, time_t freeafter,
|
|||
uint32_t h;
|
||||
h = compute_hash(key, &l);
|
||||
l++;
|
||||
he = (cache_entry_t *)psync_malloc(offsetof(cache_entry_t, key) + l);
|
||||
he = (cache_entry_t *)malloc(offsetof(cache_entry_t, key) + l);
|
||||
he->value = ptr;
|
||||
he->free = freefunc;
|
||||
he->hash = h;
|
||||
|
|
|
|||
|
|
@ -207,7 +207,7 @@ static void load_str_to(const psync_variant *v, unsigned char **ptr,
|
|||
const char *str;
|
||||
size_t l;
|
||||
str = psync_get_lstring(*v, &l);
|
||||
*ptr = (unsigned char *)psync_malloc(l);
|
||||
*ptr = (unsigned char *)malloc(l);
|
||||
memcpy(*ptr, str, l);
|
||||
*len = l;
|
||||
}
|
||||
|
|
@ -266,7 +266,7 @@ static int download_keys(unsigned char **rsapriv, size_t *rsaprivlen, unsigned c
|
|||
if (offsetof(pub_key_ver1, key) >= rsapubstructlen)
|
||||
goto def1;
|
||||
*rsapublen = rsapubstructlen - offsetof(pub_key_ver1, key);
|
||||
*rsapub = (unsigned char *)psync_malloc(*rsapublen);
|
||||
*rsapub = (unsigned char *)malloc(*rsapublen);
|
||||
memcpy(*rsapub, rsapubstruct + offsetof(pub_key_ver1, key), *rsapublen);
|
||||
break;
|
||||
default:
|
||||
|
|
@ -281,10 +281,10 @@ static int download_keys(unsigned char **rsapriv, size_t *rsaprivlen, unsigned c
|
|||
if (offsetof(priv_key_ver1, key) >= rsaprivstructlen)
|
||||
goto def2;
|
||||
*rsaprivlen = rsaprivstructlen - offsetof(priv_key_ver1, key);
|
||||
*rsapriv = (unsigned char *)psync_malloc(*rsaprivlen);
|
||||
*rsapriv = (unsigned char *)malloc(*rsaprivlen);
|
||||
memcpy(*rsapriv, rsaprivstruct + offsetof(priv_key_ver1, key), *rsaprivlen);
|
||||
*saltlen = PSYNC_CRYPTO_PBKDF2_SALT_LEN;
|
||||
*salt = (unsigned char *)psync_malloc(PSYNC_CRYPTO_PBKDF2_SALT_LEN);
|
||||
*salt = (unsigned char *)malloc(PSYNC_CRYPTO_PBKDF2_SALT_LEN);
|
||||
memcpy(*salt, rsaprivstruct + offsetof(priv_key_ver1, salt),
|
||||
PSYNC_CRYPTO_PBKDF2_SALT_LEN);
|
||||
*iterations = PSYNC_CRYPTO_PASS_TO_KEY_ITERATIONS;
|
||||
|
|
@ -333,12 +333,12 @@ setup_upload(const unsigned char *rsapriv, size_t rsaprivlen,
|
|||
int ret;
|
||||
*cryptoexpires = 0;
|
||||
priv =
|
||||
(priv_key_ver1 *)psync_malloc(offsetof(priv_key_ver1, key) + rsaprivlen);
|
||||
(priv_key_ver1 *)malloc(offsetof(priv_key_ver1, key) + rsaprivlen);
|
||||
priv->type = PSYNC_CRYPTO_TYPE_RSA4096_64BYTESALT_20000IT;
|
||||
priv->flags = 0;
|
||||
memcpy(priv->salt, salt, PSYNC_CRYPTO_PBKDF2_SALT_LEN);
|
||||
memcpy(priv->key, rsapriv, rsaprivlen);
|
||||
pub = (pub_key_ver1 *)psync_malloc(offsetof(pub_key_ver1, key) + rsapublen);
|
||||
pub = (pub_key_ver1 *)malloc(offsetof(pub_key_ver1, key) + rsapublen);
|
||||
pub->type = PSYNC_CRYPTO_PUB_TYPE_RSA4096;
|
||||
pub->flags = 0;
|
||||
memcpy(pub->key, rsapub, rsapublen);
|
||||
|
|
@ -505,7 +505,7 @@ static int crypto_keys_match() {
|
|||
psync_encrypted_symmetric_key_t enckey;
|
||||
int res;
|
||||
debug(D_NOTICE, "trying encrypt/decrypt operation with loaded keys");
|
||||
key = (psync_symmetric_key_t)psync_malloc(
|
||||
key = (psync_symmetric_key_t)malloc(
|
||||
offsetof(psync_symmetric_key_struct_t, key) + 64);
|
||||
key->keylen = 64;
|
||||
pssl_rand_strong(key->key, key->keylen);
|
||||
|
|
@ -1843,7 +1843,7 @@ int psync_pcloud_crypto_reencode_key(
|
|||
psymkey_free(aeskey);
|
||||
if (unlikely(enc == PSYNC_CRYPTO_INVALID_ENCODER))
|
||||
goto err_nm_1;
|
||||
rsaprivdec = (unsigned char *)psync_malloc(rsaprivlen);
|
||||
rsaprivdec = (unsigned char *)malloc(rsaprivlen);
|
||||
if (unlikely(!rsaprivdec)) {
|
||||
pcrypto_ctr_encdec_free(enc);
|
||||
goto err_nm_1;
|
||||
|
|
@ -1852,7 +1852,7 @@ int psync_pcloud_crypto_reencode_key(
|
|||
pcrypto_ctr_encdec_decode(enc, rsaprivdec, rsaprivlen,
|
||||
0);
|
||||
pcrypto_ctr_encdec_free(enc);
|
||||
newpriv = (unsigned char *)psync_malloc(offsetof(priv_key_ver1, key) +
|
||||
newpriv = (unsigned char *)malloc(offsetof(priv_key_ver1, key) +
|
||||
rsaprivlen);
|
||||
if (unlikely(!newpriv))
|
||||
goto err_nm_1;
|
||||
|
|
@ -1941,7 +1941,7 @@ int psync_pcloud_crypto_encode_key(const char *newpassphrase, uint32_t flags,
|
|||
goto err_nm_0;
|
||||
rsaprivlen = rsapriv->datalen;
|
||||
newpriv =
|
||||
(unsigned char *)psync_malloc(offsetof(priv_key_ver1, key) + rsaprivlen);
|
||||
(unsigned char *)malloc(offsetof(priv_key_ver1, key) + rsaprivlen);
|
||||
if (unlikely(!newpriv))
|
||||
goto err_nm_1;
|
||||
rsapriv_struct = (priv_key_ver1 *)newpriv;
|
||||
|
|
@ -2026,7 +2026,7 @@ int pcryptofolder_change_pass(const char *oldpassphrase,
|
|||
rowcnt++;
|
||||
if (!strcmp(id, "crypto_private_key")) {
|
||||
load_str_to(&row[1], &privkey, &privkeylen);
|
||||
privatekey_struct = (priv_key_ver1 *)psync_malloc(
|
||||
privatekey_struct = (priv_key_ver1 *)malloc(
|
||||
offsetof(priv_key_ver1, key) + privkeylen);
|
||||
memset(privatekey_struct, 0, offsetof(priv_key_ver1, key) + privkeylen);
|
||||
memcpy(privatekey_struct->key, privkey, privkeylen);
|
||||
|
|
@ -2035,7 +2035,7 @@ int pcryptofolder_change_pass(const char *oldpassphrase,
|
|||
free(privkey);
|
||||
} else if (!strcmp(id, "crypto_public_key")) {
|
||||
load_str_to(&row[1], &pubkey, &pubkeylen);
|
||||
pubkey_struct = (pub_key_ver1 *)psync_malloc(
|
||||
pubkey_struct = (pub_key_ver1 *)malloc(
|
||||
offsetof(pub_key_ver1, key) + pubkeylen);
|
||||
memset(pubkey_struct, 0, offsetof(pub_key_ver1, key) + pubkeylen);
|
||||
memcpy(pubkey_struct->key, pubkey, pubkeylen);
|
||||
|
|
|
|||
|
|
@ -1858,7 +1858,7 @@ static void send_share_notify(psync_eventtype_t eventid, const binresult *share,
|
|||
if ((row = psync_sql_fetch_row(res))) {
|
||||
cstr = psync_get_lstring(row[0], &sharenamelen);
|
||||
stringslen += ++sharenamelen;
|
||||
sharename = (char *)psync_malloc(sharenamelen);
|
||||
sharename = (char *)malloc(sharenamelen);
|
||||
memcpy(sharename, cstr, sharenamelen);
|
||||
freesharename = 1;
|
||||
ctime = psync_get_number(row[1]);
|
||||
|
|
@ -1871,7 +1871,7 @@ static void send_share_notify(psync_eventtype_t eventid, const binresult *share,
|
|||
return;
|
||||
}
|
||||
}
|
||||
e = (psync_share_event_t *)psync_malloc(sizeof(psync_share_event_t) +
|
||||
e = (psync_share_event_t *)malloc(sizeof(psync_share_event_t) +
|
||||
stringslen);
|
||||
str = (char *)(e + 1);
|
||||
memset(e, 0, sizeof(psync_share_event_t));
|
||||
|
|
@ -1915,7 +1915,7 @@ static void send_share_notify(psync_eventtype_t eventid, const binresult *share,
|
|||
}
|
||||
}
|
||||
if (isba) {
|
||||
notify_paramst *params = psync_malloc(sizeof(notify_paramst));
|
||||
notify_paramst *params = malloc(sizeof(notify_paramst));
|
||||
params->eventid = eventid;
|
||||
params->event_data = e;
|
||||
params->touserid = touserid;
|
||||
|
|
|
|||
|
|
@ -740,7 +740,7 @@ static int task_download_file(download_task_t *dt) {
|
|||
requestpath = papi_find_result2(res, "path", PARAM_STR)->str;
|
||||
psync_slprintf(cookie, sizeof(cookie), "Cookie: dwltag=%s\015\012",
|
||||
papi_find_result2(res, "dwltag", PARAM_STR)->str);
|
||||
buff = psync_malloc(PSYNC_COPY_BUFFER_SIZE);
|
||||
buff = malloc(PSYNC_COPY_BUFFER_SIZE);
|
||||
http = NULL;
|
||||
psync_hash_init(&hashctx);
|
||||
psync_list_for_each_element(range, &ranges, psync_range_list_t, list) {
|
||||
|
|
@ -1199,7 +1199,7 @@ static int task_run_download_file(uint64_t taskid, psync_syncid_t syncid,
|
|||
tmpname = psync_strcat(localpath, "/", filename,
|
||||
PSYNC_APPEND_PARTIAL_FILES, NULL);
|
||||
len = strlen(filename);
|
||||
dt = (download_task_t *)psync_malloc(offsetof(download_task_t, filename) +
|
||||
dt = (download_task_t *)malloc(offsetof(download_task_t, filename) +
|
||||
len + 1);
|
||||
memset(dt, 0, offsetof(download_task_t, filename));
|
||||
dt->taskid = taskid;
|
||||
|
|
@ -1591,7 +1591,7 @@ download_hashes_t *pdownload_get_hashes() {
|
|||
cnt = 0;
|
||||
pthread_mutex_lock(¤t_downloads_mutex);
|
||||
psync_list_for_each_element(dwl, &downloads, download_list_t, list) cnt++;
|
||||
ret = (download_hashes_t *)psync_malloc(
|
||||
ret = (download_hashes_t *)malloc(
|
||||
offsetof(download_hashes_t, hashes) +
|
||||
sizeof(psync_hex_hash) * cnt);
|
||||
cnt = 0;
|
||||
|
|
|
|||
|
|
@ -225,7 +225,7 @@ static void psync_free_string_list(psync_list *lst) {
|
|||
|
||||
static string_list *str_to_list_element(const char *str, size_t len) {
|
||||
string_list *le;
|
||||
le = (string_list *)psync_malloc(sizeof(string_list) + len + 1);
|
||||
le = (string_list *)malloc(sizeof(string_list) + len + 1);
|
||||
le->str = (char *)(le + 1);
|
||||
le->len = len;
|
||||
memcpy(le->str, str, len + 1);
|
||||
|
|
@ -240,7 +240,7 @@ static int psync_add_path_to_list(psync_list *lst, psync_folderid_t folderid) {
|
|||
size_t len;
|
||||
while (1) {
|
||||
if (folderid == 0) {
|
||||
e = (string_list *)psync_malloc(sizeof(string_list));
|
||||
e = (string_list *)malloc(sizeof(string_list));
|
||||
e->str = (char *)e;
|
||||
e->len = 0;
|
||||
psync_list_add_head(lst, &e->list);
|
||||
|
|
@ -297,7 +297,7 @@ static int psync_add_path_to_list_decode(psync_list *lst,
|
|||
if (folderid == 0) {
|
||||
if (e)
|
||||
psync_list_add_head(lst, &e->list);
|
||||
e = (string_list *)psync_malloc(sizeof(string_list));
|
||||
e = (string_list *)malloc(sizeof(string_list));
|
||||
e->str = (char *)e;
|
||||
e->len = 0;
|
||||
psync_list_add_head(lst, &e->list);
|
||||
|
|
@ -343,7 +343,7 @@ char *psync_join_string_list(const char *sep, psync_list *lst, size_t *retlen) {
|
|||
if (unlikely(!cnt))
|
||||
return psync_strdup("");
|
||||
seplen = strlen(sep);
|
||||
ret = str = psync_malloc(slen + cnt * seplen + 1);
|
||||
ret = str = malloc(slen + cnt * seplen + 1);
|
||||
psync_list_for_each_element(e, lst, string_list, list) {
|
||||
memcpy(str, e->str, e->len);
|
||||
str += e->len;
|
||||
|
|
@ -542,10 +542,10 @@ char *pfolder_lpath_lfile(psync_fileid_t localfileid,
|
|||
|
||||
static folder_list *folder_list_init() {
|
||||
folder_list *list;
|
||||
list = (folder_list *)psync_malloc(sizeof(folder_list));
|
||||
list = (folder_list *)malloc(sizeof(folder_list));
|
||||
list->entries =
|
||||
(pentry_t *)psync_malloc(sizeof(pentry_t) * INITIAL_ENTRY_CNT);
|
||||
list->namebuff = (char *)psync_malloc(INITIAL_NAME_BUFF);
|
||||
(pentry_t *)malloc(sizeof(pentry_t) * INITIAL_ENTRY_CNT);
|
||||
list->namebuff = (char *)malloc(INITIAL_NAME_BUFF);
|
||||
list->nameoff = 0;
|
||||
list->namealloc = INITIAL_NAME_BUFF;
|
||||
list->entriescnt = 0;
|
||||
|
|
@ -583,7 +583,7 @@ static pfolder_list_t *folder_list_finalize(folder_list *list) {
|
|||
(unsigned)(offsetof(pfolder_list_t, entries) +
|
||||
sizeof(pentry_t) * list->entriescnt + list->nameoff),
|
||||
(unsigned)list->nameoff);
|
||||
ret = (pfolder_list_t *)psync_malloc(offsetof(pfolder_list_t, entries) +
|
||||
ret = (pfolder_list_t *)malloc(offsetof(pfolder_list_t, entries) +
|
||||
sizeof(pentry_t) * list->entriescnt +
|
||||
list->nameoff);
|
||||
name = ((char *)ret) + offsetof(pfolder_list_t, entries) +
|
||||
|
|
@ -759,7 +759,7 @@ pentry_t *pfolder_stat(const char *remotepath) {
|
|||
psync_sql_bind_uint(res, 1, folderid);
|
||||
psync_sql_bind_lstring(res, 2, remotepath + len, olen);
|
||||
if ((row = psync_sql_fetch_rowint(res))) {
|
||||
ret = (pentry_t *)psync_malloc(sizeof(pentry_t) + olen + 1);
|
||||
ret = (pentry_t *)malloc(sizeof(pentry_t) + olen + 1);
|
||||
ret->folder.folderid = row[0];
|
||||
ret->folder.cansyncup = ((row[1] & PSYNC_PERM_WRITE) == PSYNC_PERM_WRITE);
|
||||
ret->folder.cansyncdown = ((row[1] & PSYNC_PERM_READ) == PSYNC_PERM_READ);
|
||||
|
|
@ -778,7 +778,7 @@ pentry_t *pfolder_stat(const char *remotepath) {
|
|||
psync_sql_bind_uint(res, 1, folderid);
|
||||
psync_sql_bind_lstring(res, 2, remotepath + len, olen);
|
||||
if ((row = psync_sql_fetch_rowint(res))) {
|
||||
ret = (pentry_t *)psync_malloc(sizeof(pentry_t) + olen + 1);
|
||||
ret = (pentry_t *)malloc(sizeof(pentry_t) + olen + 1);
|
||||
ret->file.fileid = row[0];
|
||||
ret->file.size = row[1];
|
||||
ret->name = (char *)(ret + 1);
|
||||
|
|
@ -840,7 +840,7 @@ psync_folder_list_t *pfolder_sync_folders(char *syncTypes) {
|
|||
}
|
||||
cstr = psync_get_lstring(row[2], &l);
|
||||
l++;
|
||||
str = (char *)psync_malloc(l);
|
||||
str = (char *)malloc(l);
|
||||
memcpy(str, cstr, l);
|
||||
|
||||
strlens += l;
|
||||
|
|
@ -864,7 +864,7 @@ psync_folder_list_t *pfolder_sync_folders(char *syncTypes) {
|
|||
psync_sql_free_result(res);
|
||||
l = offsetof(psync_folder_list_t, folders) +
|
||||
sizeof(psync_folder_t) * lastfolder;
|
||||
ret = (psync_folder_list_t *)psync_malloc(l + strlens);
|
||||
ret = (psync_folder_list_t *)malloc(l + strlens);
|
||||
str = ((char *)ret) + l;
|
||||
ret->foldercnt = lastfolder;
|
||||
|
||||
|
|
|
|||
|
|
@ -1017,7 +1017,7 @@ psync_fs_create_file(psync_fsfileid_t fileid, psync_fsfileid_t remotefileid,
|
|||
}
|
||||
}
|
||||
if (encoder == PSYNC_CRYPTO_INVALID_ENCODER) {
|
||||
fl = (psync_openfile_t *)psync_malloc(offsetof(psync_openfile_t, encoder));
|
||||
fl = (psync_openfile_t *)malloc(offsetof(psync_openfile_t, encoder));
|
||||
memset(fl, 0, offsetof(psync_openfile_t, encoder));
|
||||
} else {
|
||||
fl = psync_new(psync_openfile_t);
|
||||
|
|
@ -1557,7 +1557,7 @@ static int psync_fs_creat_fake_locked(psync_fspath_t *fpath,
|
|||
size_t len;
|
||||
fileid = psync_fake_fileid++;
|
||||
len = strlen(fpath->name) + 1;
|
||||
cr = (psync_fstask_creat_t *)psync_malloc(
|
||||
cr = (psync_fstask_creat_t *)malloc(
|
||||
offsetof(psync_fstask_creat_t, name) + len);
|
||||
cr->fileid = fileid;
|
||||
cr->rfileid = 0;
|
||||
|
|
@ -2649,14 +2649,14 @@ static int psync_fs_rename_static_file(psync_fstask_folder_t *srcfolder,
|
|||
dstfolder->taskscnt--;
|
||||
}
|
||||
len = strlen(new_name) + 1;
|
||||
un = (psync_fstask_unlink_t *)psync_malloc(
|
||||
un = (psync_fstask_unlink_t *)malloc(
|
||||
offsetof(psync_fstask_unlink_t, name) + len);
|
||||
un->fileid = 0;
|
||||
un->taskid = srccr->taskid;
|
||||
memcpy(un->name, new_name, len);
|
||||
psync_fstask_inject_unlink(dstfolder, un);
|
||||
addlen = psync_fstask_creat_local_offset(len - 1);
|
||||
cr = (psync_fstask_creat_t *)psync_malloc(addlen +
|
||||
cr = (psync_fstask_creat_t *)malloc(addlen +
|
||||
sizeof(psync_fstask_local_creat_t));
|
||||
cr->fileid = 0;
|
||||
cr->rfileid = 0;
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ static psync_fspath_t *ret_folder_data(psync_fsfolderid_t folderid,
|
|||
encname = pcryptofolder_fldencode_filename(enc, name);
|
||||
pcryptofolder_fldencoder_release(folderid, enc);
|
||||
len = strlen(encname);
|
||||
ret = (psync_fspath_t *)psync_malloc(sizeof(psync_fspath_t) + len + 1);
|
||||
ret = (psync_fspath_t *)malloc(sizeof(psync_fspath_t) + len + 1);
|
||||
memcpy(ret + 1, encname, len + 1);
|
||||
free(encname);
|
||||
ret->folderid = folderid;
|
||||
|
|
|
|||
|
|
@ -451,7 +451,7 @@ int psync_fstask_mkdir(psync_fsfolderid_t folderid, const char *name,
|
|||
return -EIO;
|
||||
}
|
||||
len++;
|
||||
task = (psync_fstask_mkdir_t *)psync_malloc(
|
||||
task = (psync_fstask_mkdir_t *)malloc(
|
||||
offsetof(psync_fstask_mkdir_t, name) + len);
|
||||
task->taskid = taskid;
|
||||
task->ctime = task->mtime = ctime;
|
||||
|
|
@ -655,7 +655,7 @@ int psync_fstask_rmdir(psync_fsfolderid_t folderid, uint32_t parentflags,
|
|||
return -EIO;
|
||||
}
|
||||
len++;
|
||||
task = (psync_fstask_rmdir_t *)psync_malloc(
|
||||
task = (psync_fstask_rmdir_t *)malloc(
|
||||
offsetof(psync_fstask_rmdir_t, name) + len);
|
||||
task->taskid = taskid;
|
||||
task->folderid = cfolderid;
|
||||
|
|
@ -702,14 +702,14 @@ psync_fstask_creat_t *psync_fstask_add_creat(psync_fstask_folder_t *folder,
|
|||
if (unlikely_log(psync_sql_commit_transaction()))
|
||||
return NULL;
|
||||
len++;
|
||||
un = (psync_fstask_unlink_t *)psync_malloc(
|
||||
un = (psync_fstask_unlink_t *)malloc(
|
||||
offsetof(psync_fstask_unlink_t, name) + len);
|
||||
un->fileid = -(psync_fsfileid_t)taskid;
|
||||
un->taskid = taskid;
|
||||
memcpy(un->name, name, len);
|
||||
psync_fstask_insert_into_tree(
|
||||
&folder->unlinks, offsetof(psync_fstask_unlink_t, name), &un->tree);
|
||||
task = (psync_fstask_creat_t *)psync_malloc(
|
||||
task = (psync_fstask_creat_t *)malloc(
|
||||
offsetof(psync_fstask_creat_t, name) + len);
|
||||
task->fileid = -(psync_fsfileid_t)taskid;
|
||||
task->rfileid = fileid;
|
||||
|
|
@ -777,14 +777,14 @@ psync_fstask_add_modified_file(psync_fstask_folder_t *folder, const char *name,
|
|||
if (unlikely_log(psync_sql_commit_transaction()))
|
||||
return NULL;
|
||||
len++;
|
||||
un = (psync_fstask_unlink_t *)psync_malloc(
|
||||
un = (psync_fstask_unlink_t *)malloc(
|
||||
offsetof(psync_fstask_unlink_t, name) + len);
|
||||
un->fileid = fileid;
|
||||
un->taskid = taskid;
|
||||
memcpy(un->name, name, len);
|
||||
psync_fstask_insert_into_tree(
|
||||
&folder->unlinks, offsetof(psync_fstask_unlink_t, name), &un->tree);
|
||||
task = (psync_fstask_creat_t *)psync_malloc(
|
||||
task = (psync_fstask_creat_t *)malloc(
|
||||
offsetof(psync_fstask_creat_t, name) + len);
|
||||
task->fileid = -(psync_fsfileid_t)taskid;
|
||||
task->rfileid = fileid;
|
||||
|
|
@ -866,7 +866,7 @@ int psync_fstask_add_local_creat_static(psync_fsfolderid_t folderid,
|
|||
debug(D_NOTICE, "adding file %s to folderid %ld, datalen %lu", name,
|
||||
(long)folderid, (unsigned long)datalen);
|
||||
len++;
|
||||
un = (psync_fstask_unlink_t *)psync_malloc(
|
||||
un = (psync_fstask_unlink_t *)malloc(
|
||||
offsetof(psync_fstask_unlink_t, name) + len);
|
||||
un->taskid = psync_local_taskid;
|
||||
un->fileid = 0;
|
||||
|
|
@ -874,7 +874,7 @@ int psync_fstask_add_local_creat_static(psync_fsfolderid_t folderid,
|
|||
psync_fstask_insert_into_tree(
|
||||
&folder->unlinks, offsetof(psync_fstask_unlink_t, name), &un->tree);
|
||||
addlen = psync_fstask_creat_local_offset(len - 1);
|
||||
cr = (psync_fstask_creat_t *)psync_malloc(addlen +
|
||||
cr = (psync_fstask_creat_t *)malloc(addlen +
|
||||
sizeof(psync_fstask_local_creat_t));
|
||||
cr->fileid = 0;
|
||||
cr->rfileid = 0;
|
||||
|
|
@ -1073,7 +1073,7 @@ int psync_fstask_unlink(psync_fsfolderid_t folderid, const char *name) {
|
|||
return -EIO;
|
||||
}
|
||||
len++;
|
||||
task = (psync_fstask_unlink_t *)psync_malloc(
|
||||
task = (psync_fstask_unlink_t *)malloc(
|
||||
offsetof(psync_fstask_unlink_t, name) + len);
|
||||
task->taskid = taskid;
|
||||
task->fileid = fileid;
|
||||
|
|
@ -1096,7 +1096,7 @@ static void add_history_record(psync_fileid_t fileid, psync_folderid_t folderid,
|
|||
while ((rec = (file_history_record *)pcache_get(key)))
|
||||
free(rec);
|
||||
len = strlen(name) + 1;
|
||||
rec = (file_history_record *)psync_malloc(
|
||||
rec = (file_history_record *)malloc(
|
||||
offsetof(file_history_record, name) + len);
|
||||
rec->folderid = folderid;
|
||||
memcpy(rec->name, name, len);
|
||||
|
|
@ -1176,7 +1176,7 @@ int psync_fstask_rename_file(psync_fsfileid_t fileid,
|
|||
}
|
||||
psync_fs_rename_openfile_locked(fileid, to_folderid, new_name);
|
||||
nlen++;
|
||||
rm = (psync_fstask_unlink_t *)psync_malloc(
|
||||
rm = (psync_fstask_unlink_t *)malloc(
|
||||
offsetof(psync_fstask_unlink_t, name) + nlen);
|
||||
rm->taskid = ftaskid;
|
||||
rm->fileid = fileid;
|
||||
|
|
@ -1198,14 +1198,14 @@ int psync_fstask_rename_file(psync_fsfileid_t fileid,
|
|||
free(cr);
|
||||
folder->taskscnt--;
|
||||
}
|
||||
rm = (psync_fstask_unlink_t *)psync_malloc(
|
||||
rm = (psync_fstask_unlink_t *)malloc(
|
||||
offsetof(psync_fstask_unlink_t, name) + nnlen);
|
||||
rm->fileid = fileid;
|
||||
rm->taskid = ttaskid;
|
||||
memcpy(rm->name, new_name, nnlen);
|
||||
psync_fstask_insert_into_tree(
|
||||
&folder->unlinks, offsetof(psync_fstask_unlink_t, name), &rm->tree);
|
||||
cr = (psync_fstask_creat_t *)psync_malloc(
|
||||
cr = (psync_fstask_creat_t *)malloc(
|
||||
offsetof(psync_fstask_creat_t, name) + nnlen);
|
||||
cr->fileid = fileid;
|
||||
cr->rfileid = rfileid;
|
||||
|
|
@ -1399,7 +1399,7 @@ int psync_fstask_rename_folder(psync_fsfolderid_t folderid,
|
|||
}
|
||||
|
||||
nlen++;
|
||||
rm = (psync_fstask_rmdir_t *)psync_malloc(
|
||||
rm = (psync_fstask_rmdir_t *)malloc(
|
||||
offsetof(psync_fstask_rmdir_t, name) + nlen);
|
||||
rm->taskid = ftaskid;
|
||||
rm->folderid = folderid;
|
||||
|
|
@ -1421,7 +1421,7 @@ int psync_fstask_rename_folder(psync_fsfolderid_t folderid,
|
|||
}
|
||||
|
||||
nnlen++;
|
||||
rm = (psync_fstask_rmdir_t *)psync_malloc(
|
||||
rm = (psync_fstask_rmdir_t *)malloc(
|
||||
offsetof(psync_fstask_rmdir_t, name) + nnlen);
|
||||
rm->taskid = ttaskid;
|
||||
rm->folderid = folderid;
|
||||
|
|
@ -1429,7 +1429,7 @@ int psync_fstask_rename_folder(psync_fsfolderid_t folderid,
|
|||
psync_fstask_insert_into_tree(
|
||||
&folder->rmdirs, offsetof(psync_fstask_rmdir_t, name), &rm->tree);
|
||||
|
||||
mk = (psync_fstask_mkdir_t *)psync_malloc(
|
||||
mk = (psync_fstask_mkdir_t *)malloc(
|
||||
offsetof(psync_fstask_mkdir_t, name) + nnlen);
|
||||
mk->taskid = ttaskid;
|
||||
mk->folderid = folderid;
|
||||
|
|
@ -1768,7 +1768,7 @@ static void psync_init_task_mkdir(psync_variant_row row) {
|
|||
ctime = psync_get_number(row[6]);
|
||||
folder = psync_fstask_get_or_create_folder_tasks_locked(folderid);
|
||||
len++;
|
||||
task = (psync_fstask_mkdir_t *)psync_malloc(
|
||||
task = (psync_fstask_mkdir_t *)malloc(
|
||||
offsetof(psync_fstask_mkdir_t, name) + len);
|
||||
task->taskid = taskid;
|
||||
task->ctime = task->mtime = ctime;
|
||||
|
|
@ -1804,7 +1804,7 @@ static void psync_init_task_rmdir(psync_variant_row row) {
|
|||
folder->taskscnt--;
|
||||
}
|
||||
len++;
|
||||
task = (psync_fstask_rmdir_t *)psync_malloc(
|
||||
task = (psync_fstask_rmdir_t *)malloc(
|
||||
offsetof(psync_fstask_rmdir_t, name) + len);
|
||||
task->taskid = taskid;
|
||||
task->folderid = cfolderid;
|
||||
|
|
@ -1828,14 +1828,14 @@ static void psync_init_task_creat(psync_variant_row row) {
|
|||
name = psync_get_lstring(row[4], &len);
|
||||
folder = psync_fstask_get_or_create_folder_tasks_locked(folderid);
|
||||
len++;
|
||||
un = (psync_fstask_unlink_t *)psync_malloc(
|
||||
un = (psync_fstask_unlink_t *)malloc(
|
||||
offsetof(psync_fstask_unlink_t, name) + len);
|
||||
un->fileid = -(psync_fsfileid_t)taskid;
|
||||
un->taskid = taskid;
|
||||
memcpy(un->name, name, len);
|
||||
psync_fstask_insert_into_tree(
|
||||
&folder->unlinks, offsetof(psync_fstask_unlink_t, name), &un->tree);
|
||||
task = (psync_fstask_creat_t *)psync_malloc(
|
||||
task = (psync_fstask_creat_t *)malloc(
|
||||
offsetof(psync_fstask_creat_t, name) + len);
|
||||
task->fileid = -(psync_fsfileid_t)taskid;
|
||||
task->rfileid = psync_get_number(row[3]);
|
||||
|
|
@ -1864,7 +1864,7 @@ static void psync_init_do_task_unlink(uint64_t taskid,
|
|||
folder->taskscnt--;
|
||||
}
|
||||
namelen++;
|
||||
task = (psync_fstask_unlink_t *)psync_malloc(
|
||||
task = (psync_fstask_unlink_t *)malloc(
|
||||
offsetof(psync_fstask_unlink_t, name) + namelen);
|
||||
task->taskid = taskid;
|
||||
task->fileid = fileid;
|
||||
|
|
@ -1906,7 +1906,7 @@ static void psync_init_task_renfile_from(psync_variant_row row) {
|
|||
folder->taskscnt--;
|
||||
}
|
||||
len++;
|
||||
rm = (psync_fstask_unlink_t *)psync_malloc(
|
||||
rm = (psync_fstask_unlink_t *)malloc(
|
||||
offsetof(psync_fstask_unlink_t, name) + len);
|
||||
rm->taskid = psync_get_number(row[0]);
|
||||
rm->fileid = psync_get_snumber(row[3]);
|
||||
|
|
@ -1938,14 +1938,14 @@ static void psync_init_task_renfile_to(psync_variant_row row) {
|
|||
len++;
|
||||
taskid = psync_get_number(row[0]);
|
||||
fileid = psync_get_snumber(row[3]);
|
||||
un = (psync_fstask_unlink_t *)psync_malloc(
|
||||
un = (psync_fstask_unlink_t *)malloc(
|
||||
offsetof(psync_fstask_unlink_t, name) + len);
|
||||
un->fileid = fileid;
|
||||
un->taskid = taskid;
|
||||
memcpy(un->name, name, len);
|
||||
psync_fstask_insert_into_tree(
|
||||
&folder->unlinks, offsetof(psync_fstask_creat_t, name), &un->tree);
|
||||
cr = (psync_fstask_creat_t *)psync_malloc(
|
||||
cr = (psync_fstask_creat_t *)malloc(
|
||||
offsetof(psync_fstask_creat_t, name) + len);
|
||||
cr->fileid = fileid;
|
||||
cr->rfileid = psync_get_number(row[7]);
|
||||
|
|
@ -1975,7 +1975,7 @@ static void psync_init_task_renfolder_from(psync_variant_row row) {
|
|||
folder->taskscnt--;
|
||||
}
|
||||
len++;
|
||||
rm = (psync_fstask_rmdir_t *)psync_malloc(
|
||||
rm = (psync_fstask_rmdir_t *)malloc(
|
||||
offsetof(psync_fstask_rmdir_t, name) + len);
|
||||
rm->taskid = psync_get_number(row[0]);
|
||||
rm->folderid = psync_get_snumber(row[8]);
|
||||
|
|
@ -2000,14 +2000,14 @@ static void psync_init_task_renfolder_to(psync_variant_row row) {
|
|||
len++;
|
||||
taskid = psync_get_number(row[0]);
|
||||
folderid = psync_get_snumber(row[8]);
|
||||
rm = (psync_fstask_rmdir_t *)psync_malloc(
|
||||
rm = (psync_fstask_rmdir_t *)malloc(
|
||||
offsetof(psync_fstask_rmdir_t, name) + len);
|
||||
rm->taskid = taskid;
|
||||
rm->folderid = folderid;
|
||||
memcpy(rm->name, name, len);
|
||||
psync_fstask_insert_into_tree(
|
||||
&folder->rmdirs, offsetof(psync_fstask_rmdir_t, name), &rm->tree);
|
||||
mk = (psync_fstask_mkdir_t *)psync_malloc(
|
||||
mk = (psync_fstask_mkdir_t *)malloc(
|
||||
offsetof(psync_fstask_mkdir_t, name) + len);
|
||||
mk->taskid = taskid;
|
||||
mk->folderid = folderid;
|
||||
|
|
@ -2040,14 +2040,14 @@ static void psync_init_task_modify(psync_variant_row row) {
|
|||
folder->taskscnt--;
|
||||
}
|
||||
len++;
|
||||
un = (psync_fstask_unlink_t *)psync_malloc(
|
||||
un = (psync_fstask_unlink_t *)malloc(
|
||||
offsetof(psync_fstask_unlink_t, name) + len);
|
||||
un->fileid = psync_get_snumber(row[3]);
|
||||
un->taskid = taskid;
|
||||
memcpy(un->name, name, len);
|
||||
psync_fstask_insert_into_tree(
|
||||
&folder->unlinks, offsetof(psync_fstask_unlink_t, name), &un->tree);
|
||||
cr = (psync_fstask_creat_t *)psync_malloc(
|
||||
cr = (psync_fstask_creat_t *)malloc(
|
||||
offsetof(psync_fstask_creat_t, name) + len);
|
||||
cr->fileid = -(psync_fsfileid_t)cr->taskid;
|
||||
cr->rfileid = psync_get_number(row[3]);
|
||||
|
|
@ -2119,7 +2119,7 @@ void psync_fstask_add_banned_folder(psync_fsfolderid_t folderid,
|
|||
psync_fstask_rmdir_t *rm;
|
||||
size_t len;
|
||||
len = strlen(name) + 1;
|
||||
mk = (psync_fstask_mkdir_t *)psync_malloc(
|
||||
mk = (psync_fstask_mkdir_t *)malloc(
|
||||
offsetof(psync_fstask_mkdir_t, name) + len);
|
||||
mk->taskid = 0;
|
||||
mk->ctime = mk->mtime = 0;
|
||||
|
|
@ -2127,7 +2127,7 @@ void psync_fstask_add_banned_folder(psync_fsfolderid_t folderid,
|
|||
mk->subdircnt = 0;
|
||||
mk->flags = PSYNC_FOLDER_FLAG_INVISIBLE;
|
||||
memcpy(mk->name, name, len);
|
||||
rm = (psync_fstask_rmdir_t *)psync_malloc(
|
||||
rm = (psync_fstask_rmdir_t *)malloc(
|
||||
offsetof(psync_fstask_rmdir_t, name) + len);
|
||||
rm->taskid = 0;
|
||||
rm->folderid = 0;
|
||||
|
|
|
|||
|
|
@ -796,7 +796,7 @@ static int large_upload_creat(uint64_t taskid, psync_folderid_t folderid,
|
|||
}
|
||||
if (large_upload_creat_send_write(api, uploadid, usize, fsize - usize))
|
||||
goto err1;
|
||||
buff = psync_malloc(PSYNC_COPY_BUFFER_SIZE);
|
||||
buff = malloc(PSYNC_COPY_BUFFER_SIZE);
|
||||
if (usize) {
|
||||
asize = usize;
|
||||
pupload_bytes_add(asize);
|
||||
|
|
@ -924,7 +924,7 @@ static int upload_modify_send_local(psock_t *api,
|
|||
return PSYNC_NET_TEMPFAIL;
|
||||
bw = 0;
|
||||
|
||||
buff = psync_malloc(PSYNC_COPY_BUFFER_SIZE);
|
||||
buff = malloc(PSYNC_COPY_BUFFER_SIZE);
|
||||
while (bw < length) {
|
||||
if (unlikely(stop_current_upload)) {
|
||||
debug(D_NOTICE, "got stop");
|
||||
|
|
@ -1522,7 +1522,7 @@ int2, sfolderid FROM fstask WHERE id=?"); psync_sql_bind_uint(res, 1, id);
|
|||
size+=row[4].length+1;
|
||||
if (row[5].type==PSYNC_TSTRING)
|
||||
size+=row[5].length+1;
|
||||
task=(fsupload_task_t *)psync_malloc(size);
|
||||
task=(fsupload_task_t *)malloc(size);
|
||||
end=(char *)(task+1);
|
||||
task->res=NULL;
|
||||
task->id=psync_get_number(row[0]);
|
||||
|
|
@ -2087,7 +2087,7 @@ static void psync_fsupload_check_tasks() {
|
|||
size += row[4].length + 1;
|
||||
if (row[5].type == PSYNC_TSTRING)
|
||||
size += row[5].length + 1;
|
||||
task = (fsupload_task_t *)psync_malloc(size);
|
||||
task = (fsupload_task_t *)malloc(size);
|
||||
end = (char *)(task + 1);
|
||||
task->res = NULL;
|
||||
task->id = psync_get_number(row[0]);
|
||||
|
|
|
|||
|
|
@ -183,7 +183,7 @@ char *psync_strcat(const char *str, ...) {
|
|||
size += len;
|
||||
}
|
||||
va_end(ap);
|
||||
ptr2 = ptr3 = (char *)psync_malloc(size);
|
||||
ptr2 = ptr3 = (char *)malloc(size);
|
||||
for (size = 0; size < i; size++) {
|
||||
memcpy(ptr2, strs[size], lengths[size]);
|
||||
ptr2 += lengths[size];
|
||||
|
|
@ -211,7 +211,7 @@ unsigned char *psync_base32_encode(const unsigned char *str, size_t length,
|
|||
unsigned char *p;
|
||||
uint32_t bits, buff;
|
||||
|
||||
result = (unsigned char *)psync_malloc(((length + 4) / 5) * 8 + 1);
|
||||
result = (unsigned char *)malloc(((length + 4) / 5) * 8 + 1);
|
||||
p = result;
|
||||
|
||||
bits = 0;
|
||||
|
|
@ -247,7 +247,7 @@ unsigned char *psync_base32_decode(const unsigned char *str, size_t length,
|
|||
unsigned char *result, *p;
|
||||
uint32_t bits, buff;
|
||||
unsigned char ch;
|
||||
result = (unsigned char *)psync_malloc((length + 7) / 8 * 5 + 1);
|
||||
result = (unsigned char *)malloc((length + 7) / 8 * 5 + 1);
|
||||
p = result;
|
||||
bits = 0;
|
||||
buff = 0;
|
||||
|
|
@ -280,7 +280,7 @@ unsigned char *psync_base64_encode(const unsigned char *str, size_t length,
|
|||
unsigned char *p;
|
||||
unsigned char *result;
|
||||
|
||||
result = (unsigned char *)psync_malloc(((length + 2) / 3) * 4 + 1);
|
||||
result = (unsigned char *)malloc(((length + 2) / 3) * 4 + 1);
|
||||
p = result;
|
||||
|
||||
while (length > 2) {
|
||||
|
|
@ -313,7 +313,7 @@ unsigned char *psync_base64_decode(const unsigned char *str, size_t length,
|
|||
size_t i = 0, j = 0;
|
||||
ssize_t ch;
|
||||
|
||||
result = (unsigned char *)psync_malloc((length + 3) / 4 * 3 + 1);
|
||||
result = (unsigned char *)malloc((length + 3) / 4 * 3 + 1);
|
||||
|
||||
while (length-- > 0) {
|
||||
ch = base64_reverse_table[*current++];
|
||||
|
|
@ -1080,7 +1080,7 @@ char **psync_sql_rowstr(const char *sql) {
|
|||
lens[i] = l;
|
||||
}
|
||||
ln += (sizeof(char *) + 1) * cnt;
|
||||
arr = (char **)psync_malloc(ln);
|
||||
arr = (char **)malloc(ln);
|
||||
nstr = ((char *)arr) + sizeof(char *) * cnt;
|
||||
for (i = 0; i < cnt; i++) {
|
||||
str = (char *)sqlite3_column_blob(stmt, i);
|
||||
|
|
@ -1142,7 +1142,7 @@ psync_variant *psync_sql_row(const char *sql) {
|
|||
lens[i] = l;
|
||||
}
|
||||
}
|
||||
arr = (psync_variant *)psync_malloc(ln);
|
||||
arr = (psync_variant *)malloc(ln);
|
||||
nstr = ((char *)arr) + sizeof(psync_variant) * cnt;
|
||||
for (i = 0; i < cnt; i++) {
|
||||
t = types[i];
|
||||
|
|
@ -1212,7 +1212,7 @@ psync_sql_res *psync_sql_query_nocache(const char *sql) {
|
|||
return NULL;
|
||||
}
|
||||
cnt = sqlite3_column_count(stmt);
|
||||
res = (psync_sql_res *)psync_malloc(sizeof(psync_sql_res) +
|
||||
res = (psync_sql_res *)malloc(sizeof(psync_sql_res) +
|
||||
cnt * sizeof(psync_variant));
|
||||
res->stmt = stmt;
|
||||
res->sql = sql;
|
||||
|
|
@ -1280,7 +1280,7 @@ psync_sql_res *psync_sql_query_rdlock_nocache(const char *sql) {
|
|||
return NULL;
|
||||
}
|
||||
cnt = sqlite3_column_count(stmt);
|
||||
res = (psync_sql_res *)psync_malloc(sizeof(psync_sql_res) +
|
||||
res = (psync_sql_res *)malloc(sizeof(psync_sql_res) +
|
||||
cnt * sizeof(psync_variant));
|
||||
res->stmt = stmt;
|
||||
res->sql = sql;
|
||||
|
|
@ -1347,7 +1347,7 @@ psync_sql_res *psync_sql_query_nolock_nocache(const char *sql) {
|
|||
return NULL;
|
||||
}
|
||||
cnt = sqlite3_column_count(stmt);
|
||||
res = (psync_sql_res *)psync_malloc(sizeof(psync_sql_res) +
|
||||
res = (psync_sql_res *)malloc(sizeof(psync_sql_res) +
|
||||
cnt * sizeof(psync_variant));
|
||||
res->stmt = stmt;
|
||||
res->sql = sql;
|
||||
|
|
@ -1708,7 +1708,7 @@ psync_full_result_int *psync_sql_fetchall_int(psync_sql_res *res) {
|
|||
if (unlikely(code != SQLITE_DONE))
|
||||
debug(D_ERROR, "sqlite3_step returned error: %s", sqlite3_errmsg(psync_db));
|
||||
psync_sql_free_result(res);
|
||||
ret = (psync_full_result_int *)psync_malloc(
|
||||
ret = (psync_full_result_int *)malloc(
|
||||
offsetof(psync_full_result_int, data) + sizeof(uint64_t) * off);
|
||||
ret->rows = rows;
|
||||
ret->cols = cols;
|
||||
|
|
@ -1732,7 +1732,7 @@ int psync_rename_conflicted_file(const char *path) {
|
|||
dotidx--;
|
||||
if (!dotidx)
|
||||
dotidx = plen;
|
||||
npath = (char *)psync_malloc(plen + 32);
|
||||
npath = (char *)malloc(plen + 32);
|
||||
memcpy(npath, path, dotidx);
|
||||
num = 0;
|
||||
while (1) {
|
||||
|
|
@ -1919,7 +1919,7 @@ void psync_list_bulder_add_sql(psync_list_builder_t *builder,
|
|||
while ((row = psync_sql_fetch_row(res))) {
|
||||
if (!builder->last_elements ||
|
||||
builder->last_elements->used >= builder->elements_per_list) {
|
||||
builder->last_elements = (psync_list_element_list *)psync_malloc(
|
||||
builder->last_elements = (psync_list_element_list *)malloc(
|
||||
offsetof(psync_list_element_list, elements) +
|
||||
builder->element_size * builder->elements_per_list);
|
||||
psync_list_add_tail(&builder->element_list,
|
||||
|
|
@ -1946,7 +1946,7 @@ void psync_list_bulder_add_sql(psync_list_builder_t *builder,
|
|||
void *psync_list_bulder_add_element(psync_list_builder_t *builder) {
|
||||
if (!builder->last_elements ||
|
||||
builder->last_elements->used >= builder->elements_per_list) {
|
||||
builder->last_elements = (psync_list_element_list *)psync_malloc(
|
||||
builder->last_elements = (psync_list_element_list *)malloc(
|
||||
offsetof(psync_list_element_list, elements) +
|
||||
builder->element_size * builder->elements_per_list);
|
||||
psync_list_add_tail(&builder->element_list, &builder->last_elements->list);
|
||||
|
|
@ -1970,13 +1970,13 @@ void psync_list_add_lstring_offset(psync_list_builder_t *builder, size_t offset,
|
|||
str = (char **)(builder->current_element + offset);
|
||||
builder->stringalloc += length;
|
||||
if (unlikely(length > 2000)) {
|
||||
l = (psync_list_string_list *)psync_malloc(sizeof(psync_list_string_list) +
|
||||
l = (psync_list_string_list *)malloc(sizeof(psync_list_string_list) +
|
||||
length);
|
||||
s = (char *)(l + 1);
|
||||
psync_list_add_tail(&builder->string_list, &l->list);
|
||||
} else if (!builder->last_strings || builder->last_strings->next + length >
|
||||
builder->last_strings->end) {
|
||||
l = (psync_list_string_list *)psync_malloc(sizeof(psync_list_string_list) +
|
||||
l = (psync_list_string_list *)malloc(sizeof(psync_list_string_list) +
|
||||
4000);
|
||||
s = (char *)(l + 1);
|
||||
l->next = s + length;
|
||||
|
|
@ -2108,7 +2108,7 @@ psync_task_run_tasks(psync_task_callback_t const *callbacks,
|
|||
psync_task_manager_t ret;
|
||||
struct psync_task_t_ *t;
|
||||
int i;
|
||||
ret = (psync_task_manager_t)psync_malloc(
|
||||
ret = (psync_task_manager_t)malloc(
|
||||
offsetof(struct psync_task_manager_t_, tasks) +
|
||||
sizeof(struct psync_task_t_) * cnt);
|
||||
pthread_mutex_init(&ret->mutex, NULL);
|
||||
|
|
|
|||
|
|
@ -219,8 +219,8 @@ extern "C" {
|
|||
|
||||
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
|
||||
|
||||
#define psync_new(type) (type *)psync_malloc(sizeof(type))
|
||||
#define psync_new_cnt(type, cnt) (type *)psync_malloc(sizeof(type) * (cnt))
|
||||
#define psync_new(type) (type *)malloc(sizeof(type))
|
||||
#define psync_new_cnt(type, cnt) (type *)malloc(sizeof(type) * (cnt))
|
||||
|
||||
#define psync_binhex(dst, src, cnt) \
|
||||
do { \
|
||||
|
|
|
|||
|
|
@ -97,7 +97,7 @@ static void add_dir_scan(localnotify_dir *dir, const char *path) {
|
|||
namelen = 255;
|
||||
if (namelen < sizeof(de->d_name) - 1)
|
||||
namelen = sizeof(de->d_name) - 1;
|
||||
wch = (localnotify_watch *)psync_malloc(offsetof(localnotify_watch, path) +
|
||||
wch = (localnotify_watch *)malloc(offsetof(localnotify_watch, path) +
|
||||
pl + 1 + namelen + 1);
|
||||
wch->next = dir->watches[wid % WATCH_HASH];
|
||||
dir->watches[wid % WATCH_HASH] = wch;
|
||||
|
|
@ -107,8 +107,8 @@ static void add_dir_scan(localnotify_dir *dir, const char *path) {
|
|||
memcpy(wch->path, path, pl + 1);
|
||||
if (likely_log(dh = opendir(path))) {
|
||||
entrylen = offsetof(struct dirent, d_name) + namelen + 1;
|
||||
cpath = (char *)psync_malloc(pl + namelen + 2);
|
||||
entry = (struct dirent *)psync_malloc(entrylen);
|
||||
cpath = (char *)malloc(pl + namelen + 2);
|
||||
entry = (struct dirent *)malloc(entrylen);
|
||||
memcpy(cpath, path, pl);
|
||||
if (!pl || cpath[pl - 1] != '/')
|
||||
cpath[pl++] = '/';
|
||||
|
|
@ -141,7 +141,7 @@ static void add_syncid(psync_syncid_t syncid) {
|
|||
str = psync_get_lstring(row[0], &len);
|
||||
len++;
|
||||
dir =
|
||||
(localnotify_dir *)psync_malloc(offsetof(localnotify_dir, path) + len);
|
||||
(localnotify_dir *)malloc(offsetof(localnotify_dir, path) + len);
|
||||
memcpy(dir->path, str, len);
|
||||
psync_sql_free_result(res);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -172,7 +172,7 @@ static void scanner_set_syncs_to_list(psync_list *lst,
|
|||
debug(D_WARNING, "folder %s deviceid is different, ignoring", lp);
|
||||
continue;
|
||||
}
|
||||
l = (sync_list *)psync_malloc(offsetof(sync_list, localpath) + lplen + 1);
|
||||
l = (sync_list *)malloc(offsetof(sync_list, localpath) + lplen + 1);
|
||||
l->folderid = psync_get_number(row[1]);
|
||||
l->deviceid = deviceid;
|
||||
l->syncid = psync_get_number(row[0]);
|
||||
|
|
@ -180,7 +180,7 @@ static void scanner_set_syncs_to_list(psync_list *lst,
|
|||
memcpy(l->localpath, lp, lplen + 1);
|
||||
psync_list_add_tail(lst, &l->list);
|
||||
l_full_deviceid =
|
||||
(sync_list *)psync_malloc(offsetof(sync_list, localpath) + lplen + 1);
|
||||
(sync_list *)malloc(offsetof(sync_list, localpath) + lplen + 1);
|
||||
l_full_deviceid->folderid = psync_get_number(row[1]);
|
||||
l_full_deviceid->deviceid = pfile_stat_device_full(&st);
|
||||
l_full_deviceid->syncid = psync_get_number(row[0]);
|
||||
|
|
@ -254,7 +254,7 @@ static void reload_ignored_folders() {
|
|||
homelen = strlen(home);
|
||||
}
|
||||
if (home) {
|
||||
dir = (char *)psync_malloc(dirlen + homelen - 4);
|
||||
dir = (char *)malloc(dirlen + homelen - 4);
|
||||
memcpy(dir, home, homelen);
|
||||
memcpy(dir + homelen, start + 5, dirlen - 5);
|
||||
dir[dirlen + homelen - 5] = 0;
|
||||
|
|
@ -262,7 +262,7 @@ static void reload_ignored_folders() {
|
|||
dir = NULL;
|
||||
}
|
||||
} else {
|
||||
dir = (char *)psync_malloc(dirlen + 1);
|
||||
dir = (char *)malloc(dirlen + 1);
|
||||
memcpy(dir, start, dirlen);
|
||||
dir[dirlen] = 0;
|
||||
}
|
||||
|
|
@ -297,7 +297,7 @@ static void scanner_local_entry_to_list(void *ptr, ppath_stat *st) {
|
|||
|
||||
lst = (psync_list *)ptr;
|
||||
l = strlen(st->name) + 1;
|
||||
e = (sync_folderlist *)psync_malloc(offsetof(sync_folderlist, name) + l);
|
||||
e = (sync_folderlist *)malloc(offsetof(sync_folderlist, name) + l);
|
||||
e->localid = 0;
|
||||
e->remoteid = 0;
|
||||
e->inode = pfile_stat_inode(&st->stat);
|
||||
|
|
@ -361,7 +361,7 @@ static void scanner_db_folder_to_list(psync_syncid_t syncid,
|
|||
continue;
|
||||
}
|
||||
namelen++;
|
||||
e = (sync_folderlist *)psync_malloc(offsetof(sync_folderlist, name) +
|
||||
e = (sync_folderlist *)malloc(offsetof(sync_folderlist, name) +
|
||||
namelen);
|
||||
e->localid = psync_get_number(row[0]);
|
||||
e->remoteid = psync_get_number_or_null(row[1]);
|
||||
|
|
@ -390,7 +390,7 @@ static void scanner_db_folder_to_list(psync_syncid_t syncid,
|
|||
continue;
|
||||
}
|
||||
namelen++;
|
||||
e = (sync_folderlist *)psync_malloc(offsetof(sync_folderlist, name) +
|
||||
e = (sync_folderlist *)malloc(offsetof(sync_folderlist, name) +
|
||||
namelen);
|
||||
e->localid = psync_get_number(row[0]);
|
||||
e->remoteid = psync_get_number_or_null(row[1]);
|
||||
|
|
@ -419,7 +419,7 @@ static sync_folderlist *copy_folderlist_element(const sync_folderlist *e,
|
|||
sync_folderlist *ret;
|
||||
size_t l;
|
||||
l = offsetof(sync_folderlist, name) + strlen(e->name) + 1;
|
||||
ret = (sync_folderlist *)psync_malloc(l);
|
||||
ret = (sync_folderlist *)malloc(l);
|
||||
memcpy(ret, e, l);
|
||||
ret->localparentfolderid = localfolderid;
|
||||
ret->parentfolderid = folderid;
|
||||
|
|
@ -1262,7 +1262,7 @@ void psync_restat_sync_folders_add(psync_syncid_t syncid,
|
|||
sync_restat_list *l;
|
||||
struct stat st;
|
||||
size_t lplen = strlen(localpath);
|
||||
l = (sync_restat_list *)psync_malloc(offsetof(sync_restat_list, localpath) +
|
||||
l = (sync_restat_list *)malloc(offsetof(sync_restat_list, localpath) +
|
||||
lplen + 1);
|
||||
l->syncid = syncid;
|
||||
memcpy(l->localpath, localpath, lplen + 1);
|
||||
|
|
|
|||
|
|
@ -229,7 +229,7 @@ static void mark_aligment_bytes(char *ptr, size_t from, size_t to) {
|
|||
#endif
|
||||
|
||||
void *pmemlock_malloc(size_t size) {
|
||||
return psync_malloc(size);
|
||||
return malloc(size);
|
||||
allocator_range *range, *brange;
|
||||
psync_tree *tr, **addto;
|
||||
psync_interval_tree_t *interval;
|
||||
|
|
|
|||
|
|
@ -480,7 +480,7 @@ int psync_get_local_file_checksum(const char *restrict filename,
|
|||
fd = pfile_open(filename, O_RDONLY, 0);
|
||||
if (fd == INVALID_HANDLE_VALUE)
|
||||
return PSYNC_NET_PERMFAIL;
|
||||
buff = psync_malloc(PSYNC_COPY_BUFFER_SIZE);
|
||||
buff = malloc(PSYNC_COPY_BUFFER_SIZE);
|
||||
retry:
|
||||
if (unlikely_log(fstat(fd, &st)))
|
||||
goto err1;
|
||||
|
|
@ -552,7 +552,7 @@ int psync_get_local_file_checksum_part(const char *restrict filename,
|
|||
return PSYNC_NET_PERMFAIL;
|
||||
if (unlikely_log(fstat(fd, &st)))
|
||||
goto err1;
|
||||
buff = psync_malloc(PSYNC_COPY_BUFFER_SIZE);
|
||||
buff = malloc(PSYNC_COPY_BUFFER_SIZE);
|
||||
psync_hash_init(&hctx);
|
||||
psync_hash_init(&hctxp);
|
||||
rsz = pfile_stat_size(&st);
|
||||
|
|
@ -636,7 +636,7 @@ int psync_copy_local_file_if_checksum_matches(const char *source,
|
|||
if (unlikely_log(dfd == INVALID_HANDLE_VALUE))
|
||||
goto err1;
|
||||
psync_hash_init(&hctx);
|
||||
buff = psync_malloc(PSYNC_COPY_BUFFER_SIZE);
|
||||
buff = malloc(PSYNC_COPY_BUFFER_SIZE);
|
||||
while (fsize) {
|
||||
if (fsize > PSYNC_COPY_BUFFER_SIZE)
|
||||
rrd = PSYNC_COPY_BUFFER_SIZE;
|
||||
|
|
@ -926,7 +926,7 @@ psync_http_socket *psync_http_connect(const char *host, const char *path,
|
|||
goto err0;
|
||||
} else
|
||||
debug(D_NOTICE, "got connection to %s from cache", host);
|
||||
readbuff = psync_malloc(PSYNC_HTTP_RESP_BUFFER);
|
||||
readbuff = malloc(PSYNC_HTTP_RESP_BUFFER);
|
||||
if (!addhdr)
|
||||
addhdr = "";
|
||||
if (from || to) {
|
||||
|
|
@ -1013,7 +1013,7 @@ ex:
|
|||
free(readbuff);
|
||||
readbuff = NULL;
|
||||
}
|
||||
hsock = (psync_http_socket *)psync_malloc(
|
||||
hsock = (psync_http_socket *)malloc(
|
||||
offsetof(psync_http_socket, cachekey) + cl);
|
||||
hsock->sock = sock;
|
||||
hsock->readbuff = readbuff;
|
||||
|
|
@ -1138,7 +1138,7 @@ connect_cache_tree_node_t *connect_cache_create_node(const char *host) {
|
|||
connect_cache_tree_node_t *res;
|
||||
size_t len;
|
||||
len = strlen(host) + 1;
|
||||
res = (connect_cache_tree_node_t *)psync_malloc(
|
||||
res = (connect_cache_tree_node_t *)malloc(
|
||||
offsetof(connect_cache_tree_node_t, host) + len);
|
||||
res->usessl = psync_setting_get_bool(_PS(usessl));
|
||||
res->haswaiter = 0;
|
||||
|
|
@ -1326,10 +1326,10 @@ psync_http_socket *psync_http_connect_multihost(const binresult *hosts,
|
|||
}
|
||||
}
|
||||
}
|
||||
hsock = (psync_http_socket *)psync_malloc(
|
||||
hsock = (psync_http_socket *)malloc(
|
||||
offsetof(psync_http_socket, cachekey) + cl);
|
||||
hsock->sock = sock;
|
||||
hsock->readbuff = psync_malloc(PSYNC_HTTP_RESP_BUFFER);
|
||||
hsock->readbuff = malloc(PSYNC_HTTP_RESP_BUFFER);
|
||||
;
|
||||
hsock->contentlength = -1;
|
||||
hsock->readbytes = 0;
|
||||
|
|
@ -1369,10 +1369,10 @@ psync_http_connect_multihost_from_cache(const binresult *hosts,
|
|||
}
|
||||
if (!sock)
|
||||
return NULL;
|
||||
hsock = (psync_http_socket *)psync_malloc(
|
||||
hsock = (psync_http_socket *)malloc(
|
||||
offsetof(psync_http_socket, cachekey) + cl);
|
||||
hsock->sock = sock;
|
||||
hsock->readbuff = psync_malloc(PSYNC_HTTP_RESP_BUFFER);
|
||||
hsock->readbuff = malloc(PSYNC_HTTP_RESP_BUFFER);
|
||||
;
|
||||
hsock->contentlength = -1;
|
||||
hsock->readbytes = 0;
|
||||
|
|
@ -1563,7 +1563,7 @@ char *psync_url_decode(const char *s) {
|
|||
size_t slen;
|
||||
char unsigned ch1, ch2;
|
||||
slen = strlen(s);
|
||||
ret = p = (char *)psync_malloc(slen + 1);
|
||||
ret = p = (char *)malloc(slen + 1);
|
||||
while (slen--) {
|
||||
if (*s == '+')
|
||||
*p = ' ';
|
||||
|
|
@ -1644,7 +1644,7 @@ static int psync_net_get_checksums(psock_t *api, psync_fileid_t fileid,
|
|||
psync_http_close(http);
|
||||
return PSYNC_NET_OK;
|
||||
}
|
||||
cs = (psync_file_checksums *)psync_malloc(
|
||||
cs = (psync_file_checksums *)malloc(
|
||||
offsetof(psync_file_checksums, blocks) +
|
||||
(sizeof(psync_block_checksum) + sizeof(uint32_t)) * i);
|
||||
cs->filesize = hdr.filesize;
|
||||
|
|
@ -1708,7 +1708,7 @@ static int psync_net_get_upload_checksums(psock_t *api,
|
|||
}
|
||||
if (!hdr.filesize)
|
||||
return PSYNC_NET_PERMFAIL;
|
||||
cs = (psync_file_checksums *)psync_malloc(
|
||||
cs = (psync_file_checksums *)malloc(
|
||||
offsetof(psync_file_checksums, blocks) +
|
||||
(sizeof(psync_block_checksum) + sizeof(uint32_t)) * i);
|
||||
cs->filesize = hdr.filesize;
|
||||
|
|
@ -1779,7 +1779,7 @@ psync_net_create_hash(const psync_file_checksums *checksums) {
|
|||
break;
|
||||
cnt += 2;
|
||||
}
|
||||
h = (psync_file_checksum_hash *)psync_malloc(
|
||||
h = (psync_file_checksum_hash *)malloc(
|
||||
offsetof(psync_file_checksum_hash, elements) + sizeof(uint32_t) * cnt);
|
||||
h->elementcnt = cnt;
|
||||
memset(h->elements, 0, sizeof(uint32_t) * cnt);
|
||||
|
|
@ -1997,7 +1997,7 @@ static void psync_net_check_file_for_blocks(
|
|||
else
|
||||
buffersize = PSYNC_COPY_BUFFER_SIZE;
|
||||
hbuffersize = buffersize / 2;
|
||||
buff = psync_malloc(buffersize);
|
||||
buff = malloc(buffersize);
|
||||
rd = pfile_read(fd, buff, hbuffersize);
|
||||
if (unlikely(rd < (ssize_t)hbuffersize)) {
|
||||
if (rd < (ssize_t)checksums->blocksize) {
|
||||
|
|
@ -2165,7 +2165,7 @@ static int check_range_for_blocks(psync_file_checksums *checksums,
|
|||
else
|
||||
buffersize = PSYNC_COPY_BUFFER_SIZE;
|
||||
hbuffersize = buffersize / 2;
|
||||
buff = psync_malloc(buffersize);
|
||||
buff = malloc(buffersize);
|
||||
rd = pfile_read(fd, buff, hbuffersize);
|
||||
if (unlikely(rd < (ssize_t)hbuffersize)) {
|
||||
free(buff);
|
||||
|
|
@ -2515,7 +2515,7 @@ psync_file_lock_t *psync_lock_file(const char *path) {
|
|||
size_t len;
|
||||
int cmp;
|
||||
len = strlen(path) + 1;
|
||||
lock = psync_malloc(offsetof(psync_file_lock_t, filename) + len);
|
||||
lock = malloc(offsetof(psync_file_lock_t, filename) + len);
|
||||
memcpy(lock->filename, path, len);
|
||||
pthread_mutex_lock(&file_lock_mutex);
|
||||
tr = file_lock_tree;
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@ static void psync_notifications_download_thumb(const binresult *thumb,
|
|||
goto err3;
|
||||
if (unlikely_log(psync_http_next_request(sock)))
|
||||
goto err3;
|
||||
buff = (char *)psync_malloc(PSYNC_COPY_BUFFER_SIZE);
|
||||
buff = (char *)malloc(PSYNC_COPY_BUFFER_SIZE);
|
||||
while (1) {
|
||||
rd = psync_http_request_readall(sock, buff, PSYNC_COPY_BUFFER_SIZE);
|
||||
if (rd <= 0)
|
||||
|
|
@ -258,7 +258,7 @@ static void psync_notifications_thumb_dir_list(void *ptr,
|
|||
} else
|
||||
addto = tree;
|
||||
len = strlen(st->name) + 1;
|
||||
tl = (psync_thumb_list_t *)psync_malloc(offsetof(psync_thumb_list_t, name) +
|
||||
tl = (psync_thumb_list_t *)malloc(offsetof(psync_thumb_list_t, name) +
|
||||
len);
|
||||
memcpy(tl->name, st->name, len);
|
||||
*addto = &tl->tree;
|
||||
|
|
|
|||
|
|
@ -639,7 +639,7 @@ static int psync_p2p_get_download_token(psync_fileid_t fileid,
|
|||
return PSYNC_NET_PERMFAIL;
|
||||
}
|
||||
ctoken = papi_find_result2(res, "token", PARAM_STR);
|
||||
*token = psync_malloc(ctoken->length + 1);
|
||||
*token = malloc(ctoken->length + 1);
|
||||
memcpy(*token, ctoken->str, ctoken->length + 1);
|
||||
*tlen = ctoken->length;
|
||||
free(res);
|
||||
|
|
|
|||
|
|
@ -1039,7 +1039,7 @@ static void clean_cache() {
|
|||
}
|
||||
clean_cache_in_progress = 1;
|
||||
psync_sql_sync();
|
||||
entries = (pagecache_entry *)psync_malloc(cnt * sizeof(pagecache_entry));
|
||||
entries = (pagecache_entry *)malloc(cnt * sizeof(pagecache_entry));
|
||||
i = 0;
|
||||
e = 0;
|
||||
while (i < cnt) {
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ int ppath_ls(const char *path, ppath_ls_cb callback, void *ptr) {
|
|||
}
|
||||
|
||||
pl = strlen(path);
|
||||
cpath = (char *)psync_malloc(pl + NAME_MAX + 2);
|
||||
cpath = (char *)malloc(pl + NAME_MAX + 2);
|
||||
memcpy(cpath, path, pl);
|
||||
if (!pl || cpath[pl - 1] != '/')
|
||||
cpath[pl++] = '/';
|
||||
|
|
@ -127,7 +127,7 @@ int ppath_ls_fast(const char *path, ppath_ls_fast_cb callback, void *ptr) {
|
|||
}
|
||||
|
||||
pl = strlen(path);
|
||||
cpath = (char *)psync_malloc(pl + NAME_MAX + 2);
|
||||
cpath = (char *)malloc(pl + NAME_MAX + 2);
|
||||
memcpy(cpath, path, pl);
|
||||
if (!pl || cpath[pl - 1] != '/')
|
||||
cpath[pl++] = '/';
|
||||
|
|
|
|||
|
|
@ -379,7 +379,7 @@ void pqevent_queue_sync_event_path(psync_eventtype_t eventid, psync_syncid_t syn
|
|||
else
|
||||
slen = sizeof(psync_folder_event_t);
|
||||
event =
|
||||
(event_list_t *)psync_malloc(sizeof(event_list_t) + slen + llen + rlen);
|
||||
(event_list_t *)malloc(sizeof(event_list_t) + slen + llen + rlen);
|
||||
strct = (char *)(event + 1);
|
||||
lcopy = strct + slen;
|
||||
rcopy = lcopy + llen;
|
||||
|
|
|
|||
|
|
@ -292,7 +292,7 @@ int prpc_register(int cmdid, prpc_handler h) {
|
|||
}
|
||||
|
||||
void prpc_init() {
|
||||
handlers = (prpc_handler *)psync_malloc(sizeof(prpc_handler) * handlers_size);
|
||||
handlers = (prpc_handler *)malloc(sizeof(prpc_handler) * handlers_size);
|
||||
memset(handlers, 0, sizeof(prpc_handler) * handlers_size);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -172,7 +172,7 @@ static struct addrinfo *addr_load(const char *host, const char *port) {
|
|||
psync_sql_rdunlock();
|
||||
return NULL;
|
||||
}
|
||||
ret = (struct addrinfo *)psync_malloc(sizeof(struct addrinfo) * row[0] +
|
||||
ret = (struct addrinfo *)malloc(sizeof(struct addrinfo) * row[0] +
|
||||
row[1]);
|
||||
data = (char *)(ret + row[0]);
|
||||
for (i = 0; i < row[0] - 1; i++)
|
||||
|
|
@ -517,7 +517,7 @@ void psock_set_write_buffered(psock_t *sock) {
|
|||
psock_buf_t *sb;
|
||||
if (sock->buffer)
|
||||
return;
|
||||
sb = (psock_buf_t *)psync_malloc(offsetof(psock_buf_t, buff) +
|
||||
sb = (psock_buf_t *)malloc(offsetof(psock_buf_t, buff) +
|
||||
PSYNC_FIRST_SOCK_WRITE_BUFF_SIZE);
|
||||
sb->next = NULL;
|
||||
sb->size = PSYNC_FIRST_SOCK_WRITE_BUFF_SIZE;
|
||||
|
|
@ -773,7 +773,7 @@ static int psync_socket_write_to_buf(psock_t *sock, const void *buff, int num) {
|
|||
do {
|
||||
wr = b->size - b->woffset;
|
||||
if (!wr) {
|
||||
b->next = (psock_buf_t *)psync_malloc(
|
||||
b->next = (psock_buf_t *)malloc(
|
||||
offsetof(psock_buf_t, buff) + PSYNC_SECOND_SOCK_WRITE_BUFF_SIZE);
|
||||
b = b->next;
|
||||
b->next = NULL;
|
||||
|
|
@ -1107,7 +1107,7 @@ psock_ifaces_t *psock_list_adapters() {
|
|||
}
|
||||
addr = addr->ifa_next;
|
||||
}
|
||||
ret = psync_malloc(offsetof(psock_ifaces_t, interfaces) +
|
||||
ret = malloc(offsetof(psock_ifaces_t, interfaces) +
|
||||
sizeof(psock_iface_t) * cnt);
|
||||
memset(ret, 0,
|
||||
offsetof(psock_ifaces_t, interfaces) + sizeof(psock_iface_t) * cnt);
|
||||
|
|
@ -1135,7 +1135,7 @@ psock_ifaces_t *psock_list_adapters() {
|
|||
freeifaddrs(addrs);
|
||||
return ret;
|
||||
empty:
|
||||
ret = psync_malloc(offsetof(psock_ifaces_t, interfaces));
|
||||
ret = malloc(offsetof(psock_ifaces_t, interfaces));
|
||||
ret->interfacecnt = 0;
|
||||
return ret;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ void psymkey_free(psync_symmetric_key_t key) {
|
|||
psync_encrypted_symmetric_key_t
|
||||
psymkey_alloc_encrypted(size_t len) {
|
||||
psync_encrypted_symmetric_key_t ret;
|
||||
ret = psync_malloc(offsetof(psync_encrypted_data_struct_t, data) + len);
|
||||
ret = malloc(offsetof(psync_encrypted_data_struct_t, data) + len);
|
||||
ret->datalen = len;
|
||||
return ret;
|
||||
}
|
||||
|
|
@ -94,7 +94,7 @@ psymkey_alloc_encrypted(size_t len) {
|
|||
psync_encrypted_symmetric_key_t
|
||||
psymkey_copy_encrypted(psync_encrypted_symmetric_key_t src) {
|
||||
psync_encrypted_symmetric_key_t ret;
|
||||
ret = psync_malloc(offsetof(psync_encrypted_data_struct_t, data) +
|
||||
ret = malloc(offsetof(psync_encrypted_data_struct_t, data) +
|
||||
src->datalen);
|
||||
ret->datalen = src->datalen;
|
||||
memcpy(ret->data, src->data, src->datalen);
|
||||
|
|
@ -212,7 +212,7 @@ static ssl_connection_t *conn_alloc(const char *hostname) {
|
|||
ssl_connection_t *conn;
|
||||
size_t len;
|
||||
len = strlen(hostname) + 1;
|
||||
conn = (ssl_connection_t *)psync_malloc(offsetof(ssl_connection_t, cachekey) +
|
||||
conn = (ssl_connection_t *)malloc(offsetof(ssl_connection_t, cachekey) +
|
||||
len + 4);
|
||||
conn->isbroken = 0;
|
||||
memcpy(conn->cachekey, "SSLS", 4);
|
||||
|
|
@ -718,7 +718,7 @@ prsa_encrypt_data(psync_rsa_publickey_t rsa, const unsigned char *data,
|
|||
int code;
|
||||
size_t rsalen = mbedtls_rsa_get_len(rsa);
|
||||
|
||||
ret = (psync_encrypted_symmetric_key_t)psync_malloc(
|
||||
ret = (psync_encrypted_symmetric_key_t)malloc(
|
||||
offsetof(psync_encrypted_data_struct_t, data) + rsalen);
|
||||
if ((code = mbedtls_rsa_rsaes_oaep_encrypt(
|
||||
rsa, rng_get, &rng,
|
||||
|
|
@ -799,7 +799,7 @@ prsa_sign_sha256_hash(psync_rsa_privatekey_t rsa,
|
|||
int padding, hash_id;
|
||||
size_t rsalen = mbedtls_rsa_get_len(rsa);
|
||||
|
||||
ret = (psync_rsa_signature_t)psync_malloc(
|
||||
ret = (psync_rsa_signature_t)malloc(
|
||||
offsetof(psync_symmetric_key_struct_t, key) + rsalen);
|
||||
if (!ret)
|
||||
return (psync_rsa_signature_t)(void *)PERROR_NO_MEMORY;
|
||||
|
|
|
|||
|
|
@ -115,7 +115,7 @@ static void dir_scan(void *ptr, ppath_fast_stat *st) {
|
|||
size_t l, o;
|
||||
l = strlen(st->name);
|
||||
o = f->pathlen;
|
||||
nf = (scan_folder *)psync_malloc(sizeof(scan_folder) + o + l + 2);
|
||||
nf = (scan_folder *)malloc(sizeof(scan_folder) + o + l + 2);
|
||||
psync_list_init(&nf->subfolders);
|
||||
path = (char *)(nf + 1);
|
||||
memcpy(path, f->path, o);
|
||||
|
|
@ -233,12 +233,12 @@ psuggested_folders_t *psuggest_scan_folder(const char *path) {
|
|||
ln += s->folder->pathlen + off + 2;
|
||||
sf[cnt] = s;
|
||||
descslen[cnt] = off + 1;
|
||||
descs[cnt] = psync_malloc(descslen[cnt]);
|
||||
descs[cnt] = malloc(descslen[cnt]);
|
||||
memcpy(descs[cnt], buff, descslen[cnt]);
|
||||
if (++cnt >= PSYNC_SCANNER_MAX_SUGGESTIONS)
|
||||
break;
|
||||
}
|
||||
ret = psync_malloc(offsetof(psuggested_folders_t, entries) +
|
||||
ret = malloc(offsetof(psuggested_folders_t, entries) +
|
||||
sizeof(psuggested_folder_t) * cnt + ln);
|
||||
str = ((char *)ret) + offsetof(psuggested_folders_t, entries) +
|
||||
sizeof(psuggested_folder_t) * cnt;
|
||||
|
|
|
|||
|
|
@ -148,31 +148,6 @@ PSYNC_NOINLINE void *psync_emergency_malloc(size_t size) {
|
|||
}
|
||||
}
|
||||
|
||||
void *psync_malloc(size_t size) {
|
||||
void *ptr;
|
||||
#if 1 == BUGHUNT
|
||||
void *callstack[128];
|
||||
int frames = backtrace(callstack, 128);
|
||||
char **strs = backtrace_symbols(callstack, frames);
|
||||
#endif
|
||||
ptr = psync_real_malloc(size);
|
||||
#if 1 == BUGHUNT
|
||||
printf("Allocated %zu bytes at %p\n", size, ptr);
|
||||
for (int i = 0; i < frames; i++) {
|
||||
printf("%s\n", strs[i]);
|
||||
}
|
||||
free(strs);
|
||||
#endif
|
||||
if (likely(ptr))
|
||||
#if IS_DEBUG
|
||||
return memset(ptr, 0xfa, size);
|
||||
#else
|
||||
return ptr;
|
||||
#endif
|
||||
else
|
||||
return psync_emergency_malloc(size);
|
||||
}
|
||||
|
||||
PSYNC_NOINLINE void *psync_emergency_realloc(void *ptr, size_t size) {
|
||||
void *ret;
|
||||
debug(D_WARNING, "could not reallocate %lu bytes", size);
|
||||
|
|
@ -1065,7 +1040,7 @@ int psync_is_lname_to_ignore(const char *name, size_t namelen) {
|
|||
size_t ilen, off, pl;
|
||||
char buff[120];
|
||||
if (namelen >= sizeof(buff))
|
||||
namelower = (char *)psync_malloc(namelen + 1);
|
||||
namelower = (char *)malloc(namelen + 1);
|
||||
else
|
||||
namelower = buff;
|
||||
memcpy(namelower, name, namelen);
|
||||
|
|
@ -1850,7 +1825,7 @@ static int psync_load_file(const char *local_path, char **data,
|
|||
if (fstat(fd, &st1))
|
||||
goto err1;
|
||||
len = pfile_stat_size(&st1);
|
||||
buff = psync_malloc(len);
|
||||
buff = malloc(len);
|
||||
if (!buff)
|
||||
goto err1;
|
||||
off = 0;
|
||||
|
|
@ -2898,7 +2873,7 @@ userinfo_t *psync_get_userinfo() {
|
|||
language = cres->str;
|
||||
llanguage =
|
||||
(cres->length + sizeof(void *)) / sizeof(void *) * sizeof(void *);
|
||||
info = (userinfo_t *)psync_malloc(sizeof(userinfo_t) + lemail + lcurrency +
|
||||
info = (userinfo_t *)malloc(sizeof(userinfo_t) + lemail + lcurrency +
|
||||
llanguage);
|
||||
ptr = (char *)(info + 1);
|
||||
memcpy(ptr, email, lemail);
|
||||
|
|
|
|||
|
|
@ -514,7 +514,6 @@ typedef void (*psync_free_t)(void *);
|
|||
|
||||
typedef void (*psync_generic_callback_t)();
|
||||
|
||||
void *psync_malloc(size_t size);
|
||||
void *psync_realloc(void *ptr, size_t size);
|
||||
|
||||
/* Event callback is called every time a download/upload is started/finished,
|
||||
|
|
|
|||
|
|
@ -723,7 +723,7 @@ static int sock_writeall(int sock, const void *buff, size_t len) {
|
|||
static stream_t *stream_create(async_params_t *prms, size_t addsize) {
|
||||
psync_tree *parent;
|
||||
stream_t *ret;
|
||||
ret = (stream_t *)psync_malloc(sizeof(stream_t) + addsize);
|
||||
ret = (stream_t *)malloc(sizeof(stream_t) + addsize);
|
||||
ret->streamid = ++prms->laststreamid;
|
||||
ret->flags = 0;
|
||||
ret->free = NULL;
|
||||
|
|
|
|||
|
|
@ -411,7 +411,7 @@ void ptools_send_psyncs_event(const char *binapi, const char *auth) {
|
|||
int intRes;
|
||||
int syncCnt = 0;
|
||||
|
||||
errMsg = (char *)psync_malloc(1024 * sizeof(char));
|
||||
errMsg = (char *)malloc(1024 * sizeof(char));
|
||||
errMsg[0] = 0;
|
||||
|
||||
time(&rawtime);
|
||||
|
|
|
|||
|
|
@ -110,7 +110,7 @@ static void modify_screenshot_public_link(void *par) {
|
|||
int64_t do_psync_screenshot_public_link(const char *path, int hasdelay,
|
||||
uint64_t delay, char **link /*OUT*/,
|
||||
char **err /*OUT*/) {
|
||||
scr_params *params = psync_malloc(sizeof(scr_params));
|
||||
scr_params *params = malloc(sizeof(scr_params));
|
||||
int64_t ret =
|
||||
do_psync_file_public_link(path, ¶ms->linkid, link, err, 0, 0, 0);
|
||||
if (hasdelay) {
|
||||
|
|
@ -150,7 +150,7 @@ int64_t do_psync_file_public_link(const char *path, int64_t *plinkid,
|
|||
int numparam = 2 + !!expire + !!maxdownloads + !!maxtraffic;
|
||||
int pind = 1;
|
||||
|
||||
t = (binparam *)psync_malloc(numparam * sizeof(binparam));
|
||||
t = (binparam *)malloc(numparam * sizeof(binparam));
|
||||
init_param_str(t, "auth", psync_my_auth);
|
||||
init_param_str(t + pind++, "path", path);
|
||||
if (expire)
|
||||
|
|
@ -227,7 +227,7 @@ int64_t do_psync_folder_public_link(const char *path, char **link /*OUT*/,
|
|||
int numparam = 2 + !!expire + !!maxdownloads + !!maxtraffic;
|
||||
int pind = 1;
|
||||
|
||||
t = (binparam *)psync_malloc(numparam * sizeof(binparam));
|
||||
t = (binparam *)malloc(numparam * sizeof(binparam));
|
||||
init_param_str(t, "auth", psync_my_auth);
|
||||
init_param_str(t + pind++, "path", path);
|
||||
if (expire)
|
||||
|
|
@ -301,7 +301,7 @@ int64_t do_psync_folder_public_link_full(const char *path, char **link /*OUT*/,
|
|||
int numparam = 2 + !!expire + !!maxdownloads + !!maxtraffic + !!password;
|
||||
int pind = 1;
|
||||
|
||||
t = (binparam *)psync_malloc(numparam * sizeof(binparam));
|
||||
t = (binparam *)malloc(numparam * sizeof(binparam));
|
||||
init_param_str(t, "auth", psync_my_auth);
|
||||
init_param_str(t + pind++, "path", path);
|
||||
if (password)
|
||||
|
|
@ -428,21 +428,21 @@ int64_t do_ptree_public_link(const char *linkname, const char *root,
|
|||
if (unlikely(!(!!root + !!numfolders + !!numfiles)))
|
||||
return -3;
|
||||
|
||||
t = (binparam *)psync_malloc(numparam * sizeof(binparam));
|
||||
t = (binparam *)malloc(numparam * sizeof(binparam));
|
||||
|
||||
init_param_str(t, "auth", psync_my_auth);
|
||||
|
||||
init_param_str(t + pind++, "name", linkname);
|
||||
|
||||
if (root) {
|
||||
ids = (char *)psync_malloc(FOLDERID_ENTRY_SIZE);
|
||||
ids = (char *)malloc(FOLDERID_ENTRY_SIZE);
|
||||
id = psync_fsfolderid_by_path(root, 0);
|
||||
k = sprintf(ids, "%lld", (long long)id);
|
||||
init_param_str(t + pind++, "folderid", ids);
|
||||
}
|
||||
|
||||
if (numfolders) {
|
||||
ids1 = (char *)psync_malloc(numfolders * FOLDERID_ENTRY_SIZE);
|
||||
ids1 = (char *)malloc(numfolders * FOLDERID_ENTRY_SIZE);
|
||||
idsp = ids1;
|
||||
for (i = 0; i < numfolders; ++i) {
|
||||
id = psync_fsfolderid_by_path(folders[i], 0);
|
||||
|
|
@ -462,7 +462,7 @@ int64_t do_ptree_public_link(const char *linkname, const char *root,
|
|||
psync_uint_row row;
|
||||
psync_fspath_t *filep;
|
||||
|
||||
ids2 = (char *)psync_malloc(numfiles * FOLDERID_ENTRY_SIZE);
|
||||
ids2 = (char *)malloc(numfiles * FOLDERID_ENTRY_SIZE);
|
||||
idsp = ids2;
|
||||
for (i = 0; i < numfiles; ++i) {
|
||||
psync_sql_rdlock();
|
||||
|
|
@ -798,7 +798,7 @@ int do_psync_change_link(unsigned long long linkid, unsigned long long expire,
|
|||
int numparam = 5; // +!!expire + !!maxdownloads + !!maxtraffic + !!password;
|
||||
int pind = 1;
|
||||
|
||||
t = (binparam *)psync_malloc(numparam * sizeof(binparam));
|
||||
t = (binparam *)malloc(numparam * sizeof(binparam));
|
||||
init_param_str(t, "auth", psync_my_auth);
|
||||
init_param_num(t + pind++, "linkid", linkid);
|
||||
if (linkpassword)
|
||||
|
|
@ -953,7 +953,7 @@ int64_t do_psync_upload_link(const char *path, const char *comment,
|
|||
int numparam = 3 + !!expire + !!maxspace + !!maxfiles;
|
||||
int pind = 1;
|
||||
|
||||
t = (binparam *)psync_malloc(numparam * sizeof(binparam));
|
||||
t = (binparam *)malloc(numparam * sizeof(binparam));
|
||||
init_param_str(t, "auth", psync_my_auth);
|
||||
init_param_str(t + pind++, "path", path);
|
||||
init_param_str(t + pind++, "comment", comment);
|
||||
|
|
|
|||
|
|
@ -695,7 +695,7 @@ static int upload_file(const char *localpath, const unsigned char *hashhex,
|
|||
params, ARRAY_SIZE(params), fsize, 0)))
|
||||
goto err1;
|
||||
bw = 0;
|
||||
buff = psync_malloc(PSYNC_COPY_BUFFER_SIZE);
|
||||
buff = malloc(PSYNC_COPY_BUFFER_SIZE);
|
||||
while (bw < fsize) {
|
||||
if (unlikely(upload->stop)) {
|
||||
debug(D_NOTICE, "upload of %s stopped", localpath);
|
||||
|
|
@ -809,7 +809,7 @@ static int upload_range(psock_t *api, psync_upload_range_list_t *r,
|
|||
return PSYNC_NET_TEMPFAIL;
|
||||
bw = 0;
|
||||
|
||||
buff = psync_malloc(PSYNC_COPY_BUFFER_SIZE);
|
||||
buff = malloc(PSYNC_COPY_BUFFER_SIZE);
|
||||
while (bw < r->len) {
|
||||
if (unlikely(upload->stop)) {
|
||||
debug(D_NOTICE, "upload stopped");
|
||||
|
|
@ -1602,7 +1602,7 @@ static int task_run_uploadfile(uint64_t taskid, psync_syncid_t syncid,
|
|||
psync_sql_bind_uint(res, 1, taskid);
|
||||
psync_sql_run_free(res);
|
||||
len = strlen(filename);
|
||||
ut = (upload_task_t *)psync_malloc(offsetof(upload_task_t, filename) + len +
|
||||
ut = (upload_task_t *)malloc(offsetof(upload_task_t, filename) + len +
|
||||
1);
|
||||
ut->upllist.taskid = taskid;
|
||||
ut->upllist.localfileid = localfileid;
|
||||
|
|
|
|||
|
|
@ -289,7 +289,7 @@ static void status_change(pstatus_t *status) {
|
|||
static int cryptocheck = 0;
|
||||
|
||||
char *err;
|
||||
err = (char *)psync_malloc(1024);
|
||||
err = (char *)malloc(1024);
|
||||
|
||||
std::cout << "Down: " << status->downloadstr << "| Up: " << status->uploadstr
|
||||
<< ", status is " << status2string(status->status) << std::endl;
|
||||
|
|
|
|||
Loading…
Reference in New Issue