code-style: general cleanups (#137)
* tns_clean_cache: remove unused function arg * remove malloc casting * improve consistency use sizeof(T) at the end * avoid comparing integers of different signedness * use Window type for embed and parent * remove unnecessary comparisons * remove cpp style comments * improve consistency: remove comma from the end of enumerator list * Removed useless _IMAGE_CONFIG defines * consistency: use the same order as snprintf * Resolve c89 warnings Co-authored-by: uidops <uidops@protonmail.com> Co-authored-by: Arthur Williams <taaparthur@gmail.com>
This commit is contained in:
8
thumbs.c
8
thumbs.c
@ -49,7 +49,7 @@ char* tns_cache_filepath(const char *filepath)
|
||||
if (strncmp(filepath, cache_dir, strlen(cache_dir)) != 0) {
|
||||
/* don't cache images inside the cache directory! */
|
||||
len = strlen(cache_dir) + strlen(filepath) + 2;
|
||||
cfile = (char*) emalloc(len);
|
||||
cfile = emalloc(len);
|
||||
snprintf(cfile, len, "%s/%s", cache_dir, filepath + 1);
|
||||
}
|
||||
return cfile;
|
||||
@ -120,7 +120,7 @@ end:
|
||||
}
|
||||
}
|
||||
|
||||
void tns_clean_cache(tns_t *tns)
|
||||
void tns_clean_cache(void)
|
||||
{
|
||||
int dirlen;
|
||||
char *cfile, *filename;
|
||||
@ -150,7 +150,7 @@ void tns_init(tns_t *tns, fileinfo_t *files, const int *cnt, int *sel, win_t *wi
|
||||
const char *homedir, *dsuffix = "";
|
||||
|
||||
if (cnt != NULL && *cnt > 0) {
|
||||
tns->thumbs = (thumb_t*) emalloc(*cnt * sizeof(thumb_t));
|
||||
tns->thumbs = emalloc(*cnt * sizeof(thumb_t));
|
||||
memset(tns->thumbs, 0, *cnt * sizeof(thumb_t));
|
||||
} else {
|
||||
tns->thumbs = NULL;
|
||||
@ -174,7 +174,7 @@ void tns_init(tns_t *tns, fileinfo_t *files, const int *cnt, int *sel, win_t *wi
|
||||
const char *s = "/nsxiv";
|
||||
free(cache_dir);
|
||||
len = strlen(homedir) + strlen(dsuffix) + strlen(s) + 1;
|
||||
cache_dir = (char*) emalloc(len);
|
||||
cache_dir = emalloc(len);
|
||||
snprintf(cache_dir, len, "%s%s%s", homedir, dsuffix, s);
|
||||
} else {
|
||||
error(0, 0, "Cache directory not found");
|
||||
|
Reference in New Issue
Block a user