# HG changeset patch # User Matti Hamalainen # Date 1518903671 -7200 # Node ID 0a1a65503e0b5292b7acfb098605456e2dfc3df8 # Parent 7fca448847a325567a738caaad125a5c93bd5f97 Use a macro for updating atime. diff -r 7fca448847a3 -r 0a1a65503e0b th_ioctx.c --- a/th_ioctx.c Sat Feb 17 23:35:20 2018 +0200 +++ b/th_ioctx.c Sat Feb 17 23:41:11 2018 +0200 @@ -11,6 +11,9 @@ #include +#define TH_UPDATE_ATIME do { ctx->atime = time(NULL); } while (0) + + th_ioctx *th_io_new(const th_ioctx_ops *fops, const char *filename) { th_ioctx *ctx = th_malloc0(sizeof(th_ioctx)); @@ -150,63 +153,63 @@ int thferror(th_ioctx *ctx) { - ctx->atime = time(NULL); + TH_UPDATE_ATIME; return ctx->fops->ferror(ctx); } int thfseek(th_ioctx *ctx, const off_t offset, int whence) { - ctx->atime = time(NULL); + TH_UPDATE_ATIME; return ctx->fops->fseek(ctx, offset, whence); } off_t thfsize(th_ioctx *ctx) { - ctx->atime = time(NULL); + TH_UPDATE_ATIME; return ctx->fops->fsize(ctx); } off_t thftell(th_ioctx *ctx) { - ctx->atime = time(NULL); + TH_UPDATE_ATIME; return ctx->fops->ftell(ctx); } BOOL thfeof(th_ioctx *ctx) { - ctx->atime = time(NULL); + TH_UPDATE_ATIME; return ctx->fops->feof(ctx); } int thfgetc(th_ioctx *ctx) { - ctx->atime = time(NULL); + TH_UPDATE_ATIME; return ctx->fops->fgetc(ctx); } int thfputc(int v, th_ioctx *ctx) { - ctx->atime = time(NULL); + TH_UPDATE_ATIME; return ctx->fops->fputc(v, ctx); } size_t thfread(void *ptr, size_t size, size_t nmemb, th_ioctx *ctx) { - ctx->atime = time(NULL); + TH_UPDATE_ATIME; return ctx->fops->fread(ptr, size, nmemb, ctx); } size_t thfwrite(const void *ptr, size_t size, size_t nmemb, th_ioctx *ctx) { - ctx->atime = time(NULL); + TH_UPDATE_ATIME; return ctx->fops->fwrite(ptr, size, nmemb, ctx); }