X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavformat%2Fcutils.c;h=4967d5b90c211a23823a66e7f4d087a2666964a9;hb=d9982edfed1c9285ab0f1104df6c045323433a3b;hp=dfc6f9c85ea9189ece43aff2879749862f38baca;hpb=e46e884f256f963b8b655df8c180e6faf3ee6820;p=ffmpeg diff --git a/libavformat/cutils.c b/libavformat/cutils.c index dfc6f9c85ea..4967d5b90c2 100644 --- a/libavformat/cutils.c +++ b/libavformat/cutils.c @@ -21,10 +21,10 @@ #include "avformat.h" /* add one element to a dynamic array */ -void __dynarray_add(unsigned long **tab_ptr, int *nb_ptr, unsigned long elem) +void ff_dynarray_add(intptr_t **tab_ptr, int *nb_ptr, intptr_t elem) { int nb, nb_alloc; - unsigned long *tab; + intptr_t *tab; nb = *nb_ptr; tab = *tab_ptr; @@ -33,7 +33,7 @@ void __dynarray_add(unsigned long **tab_ptr, int *nb_ptr, unsigned long elem) nb_alloc = 1; else nb_alloc = nb * 2; - tab = av_realloc(tab, nb_alloc * sizeof(unsigned long)); + tab = av_realloc(tab, nb_alloc * sizeof(intptr_t)); *tab_ptr = tab; } tab[nb++] = elem; @@ -62,7 +62,7 @@ time_t mktimegm(struct tm *tm) #define ISLEAP(y) (((y) % 4 == 0) && (((y) % 100) != 0 || ((y) % 400) == 0)) #define LEAPS_COUNT(y) ((y)/4 - (y)/100 + (y)/400) -/* this is our own gmtime_r. it differs from its POSIX counterpart in a +/* This is our own gmtime_r. It differs from its POSIX counterpart in a couple of places, though. */ struct tm *brktimegm(time_t secs, struct tm *tm) { @@ -77,11 +77,12 @@ struct tm *brktimegm(time_t secs, struct tm *tm) /* oh well, may be someone some day will invent a formula for this stuff */ y = 1970; /* start "guessing" */ - while (days >= (ISLEAP(y)?366:365)) { + while (days > 365) { ny = (y + days/366); days -= (ny - y) * 365 + LEAPS_COUNT(ny - 1) - LEAPS_COUNT(y - 1); y = ny; } + if (days==365 && !ISLEAP(y)) { days=0; y++; } md[1] = ISLEAP(y)?29:28; for (m=0; days >= md[m]; m++) days -= md[m];