:: Re: [DNG] "Common knowledge?"-quest…
Top Page
Delete this message
Reply to this message
Author: karl
Date:  
To: dng
Subject: Re: [DNG] "Common knowledge?"-question
Rainer Weikusat:
> karl@??? writes:
> > Katola2:
> > ...
> >> void another_print_start(char *name, char *what){
> >>
> >> char c[3] = " :";
> >>
> >> c[2] = name[0] & ~0x20;
> >>
> >> write(2, c+2, 1);
> >> write(2, name+1, strlen(name) -1);
> >> write(2, c, 2);
> >> write(2, what, strlen(what));
> >>
> >> }
> >
> > Why not just use writev(2) and write it one system call ?


Since people complained about allocations, I thought you could use this
and have a static struct iovec[4];, then the only allocations done
would be for simple types.

> The idea behind writev is to avoid userspace block memory copies prior

...
> that's 3 lines of code less which is "not great". In addition to this,
> both write and writev may end up writing less data than requested and
> the code for restarting a partially completed writev is more complicated
> than the same for write.


Both true.

Regards,
/Karl Hammar

-----------------------------------------------------------------------
Aspö Data
Lilla Aspö 148
S-742 94 Östhammar
Sweden
+46 173 140 57