comparison subreader.c @ 32331:3661c193c3ba

Use calloc instead of malloc and memset. Patch by Clment Bsch, ubitux gmail
author cehoyos
date Thu, 30 Sep 2010 09:10:35 +0000
parents acbe908638b2
children 12732436bc8a
comparison
equal deleted inserted replaced
32330:acbe908638b2 32331:3661c193c3ba
1923 tmp_fname_trim = malloc(len); 1923 tmp_fname_trim = malloc(len);
1924 tmp_fname_ext = malloc(len); 1924 tmp_fname_ext = malloc(len);
1925 1925
1926 tmpresult = malloc(len); 1926 tmpresult = malloc(len);
1927 1927
1928 result = malloc(sizeof(subfn)*MAX_SUBTITLE_FILES); 1928 result = calloc(MAX_SUBTITLE_FILES, sizeof(*result));
1929 memset(result, 0, sizeof(subfn)*MAX_SUBTITLE_FILES);
1930 1929
1931 subcnt = 0; 1930 subcnt = 0;
1932 1931
1933 tmp = strrchr(fname,'/'); 1932 tmp = strrchr(fname,'/');
1934 #if HAVE_DOS_PATHS 1933 #if HAVE_DOS_PATHS
2062 2061
2063 free(tmpresult); 2062 free(tmpresult);
2064 2063
2065 qsort(result, subcnt, sizeof(subfn), compare_sub_priority); 2064 qsort(result, subcnt, sizeof(subfn), compare_sub_priority);
2066 2065
2067 result2 = malloc(sizeof(char*)*(subcnt+1)); 2066 result2 = calloc(subcnt + 1, sizeof(*result2));
2068 memset(result2, 0, sizeof(char*)*(subcnt+1));
2069 2067
2070 for (i = 0; i < subcnt; i++) { 2068 for (i = 0; i < subcnt; i++) {
2071 result2[i] = result[i].fname; 2069 result2[i] = result[i].fname;
2072 } 2070 }
2073 result2[subcnt] = NULL; 2071 result2[subcnt] = NULL;