<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Jun 21, 2023 at 1:08 PM Guy Harris <<a href="mailto:gharris@sonic.net">gharris@sonic.net</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Jun 21, 2023, at 12:50 PM, enh <<a href="mailto:enh@google.com" target="_blank">enh@google.com</a>> wrote:<br>
<br>
> On Wed, Jun 21, 2023 at 12:54 AM Guy Harris <<a href="mailto:gharris@sonic.net" target="_blank">gharris@sonic.net</a>> wrote:<br>
> <br>
>> Is there some particular reason to make timezone_t an API/ABI structure, rather than a pointer to an opaque structure?<br>
> <br>
> no, my preference would be for timezone_t to be more like DIR...<br>
> <br>
> typedef struct DIR DIR;<br>
<br>
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.<br></blockquote><div><br></div><div>NetBSD exposes its `struct _dirdesc` but FreeBSD/OpenBSD don't (though they use the same name for the private struct).</div><div><br></div><div>somewhat unusually, bionic didn't start from any of the BSD's <dirent.h>, and uses exact the line i showed above, with the definition only in dirent.cpp itself.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
> 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.<br>
<br>
Does that work if the structure is opaque outside the routines that process tz files?<br>
<br>
> 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.<br>
<br>
I.e., it would be<br>
<br>
        timezone_t *tzalloc(const char *tzid);<br>
<br>
and<br>
<br>
        void tzfree(timezone_t *);</blockquote><div><br></div><div>exactly, just like opendir() and closedir().</div></div></div>