From f26451c086d66bc6f583f78774f683a744b56bca Mon Sep 17 00:00:00 2001 From: leitner Date: Wed, 7 Apr 2004 08:38:41 +0000 Subject: [PATCH] slight optimization for sending 0 bytes from a file (also fixes a FreeBSD-current sendfile breakage) --- io/iob_addfile.c | 4 +++- io/iob_addfile_close.c | 6 ++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/io/iob_addfile.c b/io/iob_addfile.c index 6275eb0..d57784a 100644 --- a/io/iob_addfile.c +++ b/io/iob_addfile.c @@ -1,7 +1,9 @@ #include "iob_internal.h" int iob_addfile(io_batch* b,int64 fd,uint64 off,uint64 n) { - iob_entry* e=array_allocate(&b->b,sizeof(iob_entry), + iob_entry* e; + if (n==0) return 1; + e=array_allocate(&b->b,sizeof(iob_entry), array_length(&b->b,sizeof(iob_entry))); if (!e) return 0; e->type=FROMFILE; diff --git a/io/iob_addfile_close.c b/io/iob_addfile_close.c index 9df76da..d8ae66a 100644 --- a/io/iob_addfile_close.c +++ b/io/iob_addfile_close.c @@ -1,8 +1,10 @@ #include "iob_internal.h" int iob_addfile_close(io_batch* b,int64 fd,uint64 off,uint64 n) { - iob_entry* e=array_allocate(&b->b,sizeof(iob_entry), - array_length(&b->b,sizeof(iob_entry))); + iob_entry* e; + if (n==0) return 1; + e=array_allocate(&b->b,sizeof(iob_entry), + array_length(&b->b,sizeof(iob_entry))); if (!e) return 0; e->type=FROMFILE_CLOSE; e->fd=fd;