Re: Safe file update library ready (sort of)
Adam Borowski <kilobyte@angband.pl> writes:
> On Wed, Jan 26, 2011 at 12:03:52PM +0100, Goswin von Brederlow wrote:
>> Shachar Shemesh <shachar@debian.org> writes:
>> > I've promised to get a library out there, and here it is. The base URL
>> > is https://github.com/Shachar/safewrite, and the actual code is at
>> > https://github.com/Shachar/safewrite/blob/master/safewrite.c
>>
>> Some things I noticed:
>>
>> That way one could use
> [..]
>> typedef struct {
>> int fd;
>> char buffer[PATH_MAX];
>> } safe_t;
>
> Except, you can't rely on PATH_MAX on any modern system. It's defined in
> Linux headers to an arbitrary value to make old code compile, but for
> example Hurd folks decided to not define it altogether to make buggy code
> fail during compilation rather than on runtime.
Right, so
typedef struct {
int fd;
char buffer[0];
} safe_t;
and allocating the struct as big as needed.
MfG
Goswin
Reply to: