diff options
author | Xavier Roche <xroche@users.noreply.github.com> | 2014-05-29 08:20:07 +0000 |
---|---|---|
committer | Xavier Roche <xroche@users.noreply.github.com> | 2014-05-29 08:20:07 +0000 |
commit | ae6d05fbb30ca8c0370b2be8cc1810b028616830 (patch) | |
tree | 0b7a239bbf51f74348f52a2281020cae5e2d2575 /src | |
parent | 803f7b5a33c74ced027f3a171a6a7966206d4e1d (diff) |
Allocation cleanup (why "+2", why ?)
Diffstat (limited to 'src')
-rw-r--r-- | src/htsback.c | 2 | ||||
-rw-r--r-- | src/htsbauth.c | 4 | ||||
-rw-r--r-- | src/htscache.c | 2 | ||||
-rw-r--r-- | src/htscore.c | 4 | ||||
-rw-r--r-- | src/htslib.c | 2 | ||||
-rw-r--r-- | src/htsparse.c | 2 | ||||
-rw-r--r-- | src/htsserver.c | 12 | ||||
-rw-r--r-- | src/htsserver.h | 2 | ||||
-rw-r--r-- | src/proxy/proxytrack.h | 2 |
9 files changed, 14 insertions, 18 deletions
diff --git a/src/htsback.c b/src/htsback.c index 7d9a41d..ecfa4e3 100644 --- a/src/htsback.c +++ b/src/htsback.c @@ -626,7 +626,7 @@ int back_finalize(httrackp * opt, cache_back * cache, struct_back * sback, FILE *fp = FOPEN(back[p].url_sav, "rb"); if (fp) { - back[p].r.adr = malloct((int) sz + 2); + back[p].r.adr = malloct((size_t) sz + 1); if (back[p].r.adr) { if (fread(back[p].r.adr, 1, sz, fp) == sz) { back[p].r.size = sz; diff --git a/src/htsbauth.c b/src/htsbauth.c index 9d9ea7c..fb40a8b 100644 --- a/src/htsbauth.c +++ b/src/htsbauth.c @@ -343,7 +343,7 @@ void cookie_insert(char *s, const char *ins) { if (strnotempty(s) == 0) { // rien à faire, juste concat strcatbuff(s, ins); } else { - buff = (char *) malloct(strlen(s) + 2); + buff = (char *) malloct(strlen(s) + 1); if (buff) { strcpybuff(buff, s); // copie temporaire strcpybuff(s, ins); // insérer @@ -360,7 +360,7 @@ void cookie_delete(char *s, size_t pos) { if (strnotempty(s + pos) == 0) { // rien à faire, effacer s[0] = '\0'; } else { - buff = (char *) malloct(strlen(s + pos) + 2); + buff = (char *) malloct(strlen(s + pos) + 1); if (buff) { strcpybuff(buff, s + pos); // copie temporaire strcpybuff(s, buff); // copier diff --git a/src/htscache.c b/src/htscache.c index dc63221..783251a 100644 --- a/src/htscache.c +++ b/src/htscache.c @@ -2085,7 +2085,7 @@ char *readfile_or(const char *fil, const char *defaultdata) { if (ret) return ret; else { - char *adr = malloct(strlen(defaultdata) + 2); + char *adr = malloct(strlen(defaultdata) + 1); if (adr) { strcpybuff(adr, defaultdata); diff --git a/src/htscore.c b/src/htscore.c index bf4cd98..e754c39 100644 --- a/src/htscore.c +++ b/src/htscore.c @@ -717,7 +717,7 @@ int httpmirror(char *url1, httrackp * opt) { FILE *fp = fopen(StringBuff(opt->filelist), "rb"); if (fp) { - filelist_buff = malloct(filelist_sz + 2); + filelist_buff = malloct(filelist_sz + 1); if (filelist_buff) { if (fread(filelist_buff, 1, filelist_sz, fp) != filelist_sz) { freet(filelist_buff); @@ -1384,7 +1384,7 @@ int httpmirror(char *url1, httrackp * opt) { // if (sz < 8192) { // ok, small file --> to parse! // FILE* fp=FOPEN(savename(),"rb"); // if (fp) { - // r.adr=malloct((int)sz + 2); + // r.adr=malloct(sz + 1); // if (r.adr) { // if (fread(r.adr,1,sz,fp) == sz) { // r.size=sz; diff --git a/src/htslib.c b/src/htslib.c index 9c06cd5..c058733 100644 --- a/src/htslib.c +++ b/src/htslib.c @@ -3081,7 +3081,7 @@ int linputsoc_t(T_SOC soc, char *s, int max, int timeout) { } int linput_trim(FILE * fp, char *s, int max) { int rlen = 0; - char *ls = (char *) malloct(max + 2); + char *ls = (char *) malloct(max + 1); s[0] = '\0'; if (ls) { diff --git a/src/htsparse.c b/src/htsparse.c index 1e431b4..032af7c 100644 --- a/src/htsparse.c +++ b/src/htsparse.c @@ -2098,7 +2098,7 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { while((lien[0] == '.') && (lien[1] == '/')) { char BIGSTK tempo[HTS_URLMAXSIZE * 2]; - strcpybuff(tempo, lien + 2); + strcpybuff(tempo, lien + 1); strcpybuff(lien, tempo); } if (strnotempty(lien) == 0) // sauf si plus de nom de fichier diff --git a/src/htsserver.c b/src/htsserver.c index 3ac0d9d..2e840e1 100644 --- a/src/htsserver.c +++ b/src/htsserver.c @@ -1497,11 +1497,9 @@ static int htslang_load(char *limit_to, const char *path) { if (!strnotempty(test)) { // éviter doublons // conv_printf(key,key); - int len; - char *buff; + const size_t len = strlen(intkey); + char *const buff = (char *) malloc(len + 1); - len = (int) strlen(intkey); - buff = (char *) malloc(len + 2); if (buff) { strcpybuff(buff, intkey); inthash_add(NewLangStrKeys, key, (intptr_t) buff); @@ -1561,8 +1559,6 @@ static int htslang_load(char *limit_to, const char *path) { linput_cpp(fp, extkey, 8000); linput_cpp(fp, value, 8000); if (strnotempty(extkey) && strnotempty(value)) { - int len; - char *buff; const char *intkey; intkey = LANGINTKEY(extkey); @@ -1599,8 +1595,8 @@ static int htslang_load(char *limit_to, const char *path) { /* Add key */ if (strnotempty(intkey)) { - len = (int) strlen(value); - buff = (char *) malloc(len + 2); + const size_t len = strlen(value); + char *const buff = (char *) malloc(len + 2); if (buff) { conv_printf(value, buff); inthash_add(NewLangStr, intkey, (intptr_t) buff); diff --git a/src/htsserver.h b/src/htsserver.h index 7daeec0..0db7e1c 100644 --- a/src/htsserver.h +++ b/src/htsserver.h @@ -228,7 +228,7 @@ static int linput(FILE * fp, char *s, int max) { } static int linput_trim(FILE * fp, char *s, int max) { int rlen = 0; - char *ls = (char *) malloc(max + 2); + char *ls = (char *) malloc(max + 1); s[0] = '\0'; if (ls) { diff --git a/src/proxy/proxytrack.h b/src/proxy/proxytrack.h index 6e4f755..b42f134 100644 --- a/src/proxy/proxytrack.h +++ b/src/proxy/proxytrack.h @@ -216,7 +216,7 @@ HTS_UNUSED static const char *jump_protocol_and_auth(const char *source) { #endif HTS_UNUSED static int linput_trim(FILE * fp, char *s, int max) { int rlen = 0; - char *ls = (char *) malloc(max + 2); + char *const ls = (char *) malloc(max + 1); s[0] = '\0'; if (ls) { |