@@ -110,7 +110,7 @@ typedef unsigned char uchar;
110
110
111
111
#define RET (i ) {s->cur = cursor; return i;}
112
112
113
- #define timelib_string_free free
113
+ #define timelib_string_free timelib_free
114
114
115
115
#define TIMELIB_HAVE_TIME () { if (s->time->have_time) { add_error(s, "Double time specification"); timelib_string_free(str); return TIMELIB_ERROR; } else { s->time->have_time = 1; s->time->h = 0; s->time->i = 0; s->time->s = 0; s->time->f = 0; } }
116
116
#define TIMELIB_UNHAVE_TIME () { s->time->have_time = 0; s->time->h = 0; s->time->i = 0; s->time->s = 0; s->time->f = 0; }
@@ -322,15 +322,15 @@ uchar *fill(Scanner *s, uchar *cursor){
322
322
s -> lim -= cnt ;
323
323
}
324
324
if ((s -> top - s -> lim ) < BSIZE ){
325
- uchar * buf = (uchar * ) malloc (((s -> lim - s -> bot ) + BSIZE )* sizeof (uchar ));
325
+ uchar * buf = (uchar * ) timelib_malloc (((s -> lim - s -> bot ) + BSIZE )* sizeof (uchar ));
326
326
memcpy (buf , s -> tok , s -> lim - s -> tok );
327
327
s -> tok = buf ;
328
328
s -> ptr = & buf [s -> ptr - s -> bot ];
329
329
cursor = & buf [cursor - s -> bot ];
330
330
s -> pos = & buf [s -> pos - s -> bot ];
331
331
s -> lim = & buf [s -> lim - s -> bot ];
332
332
s -> top = & s -> lim [BSIZE ];
333
- free (s -> bot );
333
+ timelib_free (s -> bot );
334
334
s -> bot = buf ;
335
335
}
336
336
if ((cnt = read (s -> fd , (char * ) s -> lim , BSIZE )) != BSIZE ){
@@ -345,37 +345,37 @@ uchar *fill(Scanner *s, uchar *cursor){
345
345
static void add_warning (Scanner * s , char * error )
346
346
{
347
347
s -> errors -> warning_count ++ ;
348
- s -> errors -> warning_messages = realloc (s -> errors -> warning_messages , s -> errors -> warning_count * sizeof (timelib_error_message ));
348
+ s -> errors -> warning_messages = timelib_realloc (s -> errors -> warning_messages , s -> errors -> warning_count * sizeof (timelib_error_message ));
349
349
s -> errors -> warning_messages [s -> errors -> warning_count - 1 ].position = s -> tok ? s -> tok - s -> str : 0 ;
350
350
s -> errors -> warning_messages [s -> errors -> warning_count - 1 ].character = s -> tok ? * s -> tok : 0 ;
351
- s -> errors -> warning_messages [s -> errors -> warning_count - 1 ].message = strdup (error );
351
+ s -> errors -> warning_messages [s -> errors -> warning_count - 1 ].message = timelib_strdup (error );
352
352
}
353
353
354
354
static void add_error (Scanner * s , char * error )
355
355
{
356
356
s -> errors -> error_count ++ ;
357
- s -> errors -> error_messages = realloc (s -> errors -> error_messages , s -> errors -> error_count * sizeof (timelib_error_message ));
357
+ s -> errors -> error_messages = timelib_realloc (s -> errors -> error_messages , s -> errors -> error_count * sizeof (timelib_error_message ));
358
358
s -> errors -> error_messages [s -> errors -> error_count - 1 ].position = s -> tok ? s -> tok - s -> str : 0 ;
359
359
s -> errors -> error_messages [s -> errors -> error_count - 1 ].character = s -> tok ? * s -> tok : 0 ;
360
- s -> errors -> error_messages [s -> errors -> error_count - 1 ].message = strdup (error );
360
+ s -> errors -> error_messages [s -> errors -> error_count - 1 ].message = timelib_strdup (error );
361
361
}
362
362
363
363
static void add_pbf_warning (Scanner * s , char * error , char * sptr , char * cptr )
364
364
{
365
365
s -> errors -> warning_count ++ ;
366
- s -> errors -> warning_messages = realloc (s -> errors -> warning_messages , s -> errors -> warning_count * sizeof (timelib_error_message ));
366
+ s -> errors -> warning_messages = timelib_realloc (s -> errors -> warning_messages , s -> errors -> warning_count * sizeof (timelib_error_message ));
367
367
s -> errors -> warning_messages [s -> errors -> warning_count - 1 ].position = cptr - sptr ;
368
368
s -> errors -> warning_messages [s -> errors -> warning_count - 1 ].character = * cptr ;
369
- s -> errors -> warning_messages [s -> errors -> warning_count - 1 ].message = strdup (error );
369
+ s -> errors -> warning_messages [s -> errors -> warning_count - 1 ].message = timelib_strdup (error );
370
370
}
371
371
372
372
static void add_pbf_error (Scanner * s , char * error , char * sptr , char * cptr )
373
373
{
374
374
s -> errors -> error_count ++ ;
375
- s -> errors -> error_messages = realloc (s -> errors -> error_messages , s -> errors -> error_count * sizeof (timelib_error_message ));
375
+ s -> errors -> error_messages = timelib_realloc (s -> errors -> error_messages , s -> errors -> error_count * sizeof (timelib_error_message ));
376
376
s -> errors -> error_messages [s -> errors -> error_count - 1 ].position = cptr - sptr ;
377
377
s -> errors -> error_messages [s -> errors -> error_count - 1 ].character = * cptr ;
378
- s -> errors -> error_messages [s -> errors -> error_count - 1 ].message = strdup (error );
378
+ s -> errors -> error_messages [s -> errors -> error_count - 1 ].message = timelib_strdup (error );
379
379
}
380
380
381
381
static timelib_sll timelib_meridian (char * * ptr , timelib_sll h )
@@ -439,7 +439,7 @@ static timelib_sll timelib_meridian_with_check(char **ptr, timelib_sll h)
439
439
440
440
static char * timelib_string (Scanner * s )
441
441
{
442
- char * tmp = calloc (1 , s -> cur - s -> tok + 1 );
442
+ char * tmp = timelib_calloc (1 , s -> cur - s -> tok + 1 );
443
443
memcpy (tmp , s -> tok , s -> cur - s -> tok );
444
444
445
445
return tmp ;
@@ -466,10 +466,10 @@ static timelib_sll timelib_get_nr_ex(char **ptr, int max_length, int *scanned_le
466
466
if (scanned_length ) {
467
467
* scanned_length = end - begin ;
468
468
}
469
- str = calloc (1 , end - begin + 1 );
469
+ str = timelib_calloc (1 , end - begin + 1 );
470
470
memcpy (str , begin , end - begin );
471
471
tmp_nr = strtoll (str , NULL , 10 );
472
- free (str );
472
+ timelib_free (str );
473
473
return tmp_nr ;
474
474
}
475
475
@@ -506,13 +506,13 @@ static double timelib_get_frac_nr(char **ptr, int max_length)
506
506
++ len ;
507
507
}
508
508
end = * ptr ;
509
- str = calloc (1 , end - begin + 1 );
509
+ str = timelib_calloc (1 , end - begin + 1 );
510
510
memcpy (str , begin , end - begin );
511
511
if (str [0 ] == ':' ) {
512
512
str [0 ] = '.' ;
513
513
}
514
514
tmp_nr = strtod (str , NULL );
515
- free (str );
515
+ timelib_free (str );
516
516
return tmp_nr ;
517
517
}
518
518
@@ -548,7 +548,7 @@ static timelib_sll timelib_lookup_relative_text(char **ptr, int *behavior)
548
548
++ * ptr ;
549
549
}
550
550
end = * ptr ;
551
- word = calloc (1 , end - begin + 1 );
551
+ word = timelib_calloc (1 , end - begin + 1 );
552
552
memcpy (word , begin , end - begin );
553
553
554
554
for (tp = timelib_reltext_lookup ; tp -> name ; tp ++ ) {
@@ -558,7 +558,7 @@ static timelib_sll timelib_lookup_relative_text(char **ptr, int *behavior)
558
558
}
559
559
}
560
560
561
- free (word );
561
+ timelib_free (word );
562
562
return value ;
563
563
}
564
564
@@ -581,7 +581,7 @@ static timelib_long timelib_lookup_month(char **ptr)
581
581
++ * ptr ;
582
582
}
583
583
end = * ptr ;
584
- word = calloc (1 , end - begin + 1 );
584
+ word = timelib_calloc (1 , end - begin + 1 );
585
585
memcpy (word , begin , end - begin );
586
586
587
587
for (tp = timelib_month_lookup ; tp -> name ; tp ++ ) {
@@ -590,7 +590,7 @@ static timelib_long timelib_lookup_month(char **ptr)
590
590
}
591
591
}
592
592
593
- free (word );
593
+ timelib_free (word );
594
594
return value ;
595
595
}
596
596
@@ -628,7 +628,7 @@ static const timelib_relunit* timelib_lookup_relunit(char **ptr)
628
628
++ * ptr ;
629
629
}
630
630
end = * ptr ;
631
- word = calloc (1 , end - begin + 1 );
631
+ word = timelib_calloc (1 , end - begin + 1 );
632
632
memcpy (word , begin , end - begin );
633
633
634
634
for (tp = timelib_relunit_lookup ; tp -> name ; tp ++ ) {
@@ -638,7 +638,7 @@ static const timelib_relunit* timelib_lookup_relunit(char **ptr)
638
638
}
639
639
}
640
640
641
- free (word );
641
+ timelib_free (word );
642
642
return value ;
643
643
}
644
644
@@ -723,7 +723,7 @@ static timelib_long timelib_lookup_abbr(char **ptr, int *dst, char **tz_abbr, in
723
723
++ * ptr ;
724
724
}
725
725
end = * ptr ;
726
- word = calloc (1 , end - begin + 1 );
726
+ word = timelib_calloc (1 , end - begin + 1 );
727
727
memcpy (word , begin , end - begin );
728
728
729
729
if ((tp = abbr_search (word , -1 , 0 ))) {
@@ -790,7 +790,7 @@ timelib_long timelib_parse_zone(char **ptr, int *dst, timelib_time *t, int *tz_n
790
790
found ++ ;
791
791
}
792
792
}
793
- free (tz_abbr );
793
+ timelib_free (tz_abbr );
794
794
* tz_not_found = (found == 0 );
795
795
retval = offset ;
796
796
}
@@ -803,10 +803,10 @@ timelib_long timelib_parse_zone(char **ptr, int *dst, timelib_time *t, int *tz_n
803
803
#define timelib_split_free (arg ) { \
804
804
int i; \
805
805
for (i = 0; i < arg.c; i++) { \
806
- free (arg.v[i]); \
806
+ timelib_free (arg.v[i]); \
807
807
} \
808
808
if (arg.v) { \
809
- free (arg.v); \
809
+ timelib_free (arg.v); \
810
810
} \
811
811
}
812
812
@@ -1734,7 +1734,7 @@ timelib_time* timelib_strtotime(char *s, size_t len, struct timelib_error_contai
1734
1734
char * e = s + len - 1 ;
1735
1735
1736
1736
memset (& in , 0 , sizeof (in ));
1737
- in .errors = malloc (sizeof (struct timelib_error_container ));
1737
+ in .errors = timelib_malloc (sizeof (struct timelib_error_container ));
1738
1738
in .errors -> warning_count = 0 ;
1739
1739
in .errors -> warning_messages = NULL;
1740
1740
in .errors -> error_count = 0 ;
@@ -1762,7 +1762,7 @@ timelib_time* timelib_strtotime(char *s, size_t len, struct timelib_error_contai
1762
1762
}
1763
1763
e ++ ;
1764
1764
1765
- in .str = malloc ((e - s ) + YYMAXFILL );
1765
+ in .str = timelib_malloc ((e - s ) + YYMAXFILL );
1766
1766
memset (in .str , 0 , (e - s ) + YYMAXFILL );
1767
1767
memcpy (in .str , s , (e - s ));
1768
1768
in .lim = in .str + (e - s ) + YYMAXFILL ;
@@ -1798,7 +1798,7 @@ timelib_time* timelib_strtotime(char *s, size_t len, struct timelib_error_contai
1798
1798
add_warning (& in , "The parsed date was invalid ");
1799
1799
}
1800
1800
1801
- free (in .str );
1801
+ timelib_free (in .str );
1802
1802
if (errors ) {
1803
1803
* errors = in .errors ;
1804
1804
} else {
@@ -1849,7 +1849,7 @@ timelib_time *timelib_parse_from_format(char *format, char *string, size_t len,
1849
1849
int allow_extra = 0 ;
1850
1850
1851
1851
memset (& in , 0 , sizeof (in ));
1852
- in .errors = malloc (sizeof (struct timelib_error_container ));
1852
+ in .errors = timelib_malloc (sizeof (struct timelib_error_container ));
1853
1853
in .errors -> warning_count = 0 ;
1854
1854
in .errors -> warning_messages = NULL;
1855
1855
in .errors -> error_count = 0 ;
@@ -2192,14 +2192,14 @@ void timelib_fill_holes(timelib_time *parsed, timelib_time *now, int options)
2192
2192
if (parsed -> dst == TIMELIB_UNSET ) parsed -> dst = now -> dst != TIMELIB_UNSET ? now -> dst : 0 ;
2193
2193
2194
2194
if (!parsed -> tz_abbr ) {
2195
- parsed -> tz_abbr = now -> tz_abbr ? strdup (now -> tz_abbr ) : NULL ;
2195
+ parsed -> tz_abbr = now -> tz_abbr ? timelib_strdup (now -> tz_abbr ) : NULL ;
2196
2196
}
2197
2197
if (!parsed -> tz_info ) {
2198
2198
parsed -> tz_info = now -> tz_info ? (!(options & TIMELIB_NO_CLONE ) ? timelib_tzinfo_clone (now -> tz_info ) : now -> tz_info ) : NULL ;
2199
2199
}
2200
2200
if (parsed -> zone_type == 0 && now -> zone_type != 0 ) {
2201
2201
parsed -> zone_type = now -> zone_type ;
2202
- /* parsed->tz_abbr = now->tz_abbr ? strdup (now->tz_abbr) : NULL;
2202
+ /* parsed->tz_abbr = now->tz_abbr ? timelib_strdup (now->tz_abbr) : NULL;
2203
2203
parsed->tz_info = now->tz_info ? timelib_tzinfo_clone(now->tz_info) : NULL;
2204
2204
*/ parsed -> is_localtime = 1 ;
2205
2205
}
0 commit comments