Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Wed, 21 Jun 2023 13:08:40 -0700
From: Guy Harris <gharris@...ic.net>
To: enh <enh@...gle.com>
Cc: Paul Eggert <eggert@...ucla.edu>, Time zone mailing list <tz@...a.org>,
        libc-coord@...ts.openwall.com
Subject: Re: [tz] thread-safe localtime() for an arbitrary
 timezone

On Jun 21, 2023, at 12:50 PM, enh <enh@...gle.com> wrote:

> On Wed, Jun 21, 2023 at 12:54 AM Guy Harris <gharris@...ic.net> wrote:
> 
>> Is there some particular reason to make timezone_t an API/ABI structure, rather than a pointer to an opaque structure?
> 
> no, my preference would be for timezone_t to be more like DIR...
> 
> typedef struct DIR DIR;

Like DIR, which, at least in macOS (and thus probably in most *BSDs), is fully defined in <dirent.>, or like pcap_t, which is "defined" as an opaque structure in <pcap/pcap.h> and only defined fully in a header internal to libpcap?  (And, yes, pcap_t's contents are subject to change over time, have been changed over time, and will continue to change over time.

> means you need to write the * in signatures, but that std::unique_ptr-style safe usage "just works" without having to talk about the underlying struct or use std::remove_pointer.

Does that work if the structure is opaque outside the routines that process tz files?

> Presumably if it's a structure, "tzalloc()" really means "given a tzid, fill in a structure as appropriate for that tzid, and return that structure", not "allocate a structure, fill it in as appropriate for the tzid, and return a pointer to that structure", and "tzfree()" means "free up anything pointed to by the structure whose value was passed to it" rather than "free everything pointed to by the structure pointed to by the argument and then free the structure".  If you want to do that, perhaps names that don't imply that they allocate and free a timezone_t should be chosen.

I.e., it would be

	timezone_t *tzalloc(const char *tzid);

and

	void tzfree(timezone_t *);

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.