609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
|
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
|
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
|
return ret + 1;
}
- (size_t)writeFormat: (OFString*)fmt, ...
{
va_list args;
size_t ret;
char *t;
va_start(args, fmt);
ret = [self writeFormat: fmt
withArguments: args];
va_end(args);
return ret;
}
- (size_t)writeFormat: (OFString*)fmt
withArguments: (va_list)args
{
size_t len;
char *t;
if (fmt == nil)
@throw [OFInvalidArgumentException newWithClass: isa
selector: _cmd];
va_start(args, fmt);
if ((len = vasprintf(&t, [fmt cString], args)) == -1) {
/*
* This is only the most likely error to happen. Unfortunately,
* there is no good way to check what really happened.
*/
@throw [OFOutOfMemoryException newWithClass: isa];
}
va_end(args);
@try {
return [self writeNBytes: len
fromBuffer: t];
} @finally {
free(t);
}
|