diff options
| author | Junio C Hamano <gitster@pobox.com> | 2022-02-25 15:47:36 -0800 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2022-02-25 15:47:36 -0800 |
| commit | 0a01df08c03fe707e22795de7bd1d763ed02e9e1 (patch) | |
| tree | b9ff98081b5cacb5106d303d21378cc5aeb99278 /date.c | |
| parent | Merge branch 'jc/name-rev-stdin' (diff) | |
| parent | date API: add and use a date_mode_release() (diff) | |
| download | git-0a01df08c03fe707e22795de7bd1d763ed02e9e1.tar.gz git-0a01df08c03fe707e22795de7bd1d763ed02e9e1.zip | |
Merge branch 'ab/date-mode-release'
Plug (some) memory leaks around parse_date_format().
* ab/date-mode-release:
date API: add and use a date_mode_release()
date API: add basic API docs
date API: provide and use a DATE_MODE_INIT
date API: create a date.h, split from cache.h
cache.h: remove always unused show_date_human() declaration
Diffstat (limited to 'date.c')
| -rw-r--r-- | date.c | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -5,6 +5,7 @@ */ #include "cache.h" +#include "date.h" /* * This is like mktime, but without normalization of tm_wday and tm_yday. @@ -205,11 +206,10 @@ void show_date_relative(timestamp_t time, struct strbuf *timebuf) struct date_mode *date_mode_from_type(enum date_mode_type type) { - static struct date_mode mode; + static struct date_mode mode = DATE_MODE_INIT; if (type == DATE_STRFTIME) BUG("cannot create anonymous strftime date_mode struct"); mode.type = type; - mode.local = 0; return &mode; } @@ -993,6 +993,11 @@ void parse_date_format(const char *format, struct date_mode *mode) die("unknown date format %s", format); } +void date_mode_release(struct date_mode *mode) +{ + free((char *)mode->strftime_fmt); +} + void datestamp(struct strbuf *out) { time_t now; |
