summaryrefslogtreecommitdiff
path: root/git-compat-util.h
diff options
context:
space:
mode:
authorHeikki Orsila <heikki.orsila@iki.fi>2008-04-27 12:48:30 +0300
committerJunio C Hamano <gitster@pobox.com>2008-04-27 22:22:14 -0700
commite8729f5380788855943c69f749eb5e276c3b8310 (patch)
tree1043c8df7849d793fb7027ccd1e0b38ae94d6220 /git-compat-util.h
parent633d1fe9d0f8993c4e0ceb9d166a550344cbe5f9 (diff)
downloadgit-e8729f5380788855943c69f749eb5e276c3b8310.tar.gz
Document functions xmemdupz(), xread() and xwrite()
Signed-off-by: Heikki Orsila <heikki.orsila@iki.fi> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'git-compat-util.h')
-rw-r--r--git-compat-util.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/git-compat-util.h b/git-compat-util.h
index a18235e6d0..167c3fe63a 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -268,6 +268,12 @@ static inline void *xmalloc(size_t size)
return ret;
}
+/*
+ * xmemdupz() allocates (len + 1) bytes of memory, duplicates "len" bytes of
+ * "data" to the allocated memory, zero terminates the allocated memory,
+ * and returns a pointer to the allocated memory. If the allocation fails,
+ * the program dies.
+ */
static inline void *xmemdupz(const void *data, size_t len)
{
char *p = xmalloc(len + 1);
@@ -329,6 +335,11 @@ static inline void *xmmap(void *start, size_t length,
return ret;
}
+/*
+ * xread() is the same a read(), but it automatically restarts read()
+ * operations with a recoverable error (EAGAIN and EINTR). xread()
+ * DOES NOT GUARANTEE that "len" bytes is read even if the data is available.
+ */
static inline ssize_t xread(int fd, void *buf, size_t len)
{
ssize_t nr;
@@ -340,6 +351,11 @@ static inline ssize_t xread(int fd, void *buf, size_t len)
}
}
+/*
+ * xwrite() is the same a write(), but it automatically restarts write()
+ * operations with a recoverable error (EAGAIN and EINTR). xwrite() DOES NOT
+ * GUARANTEE that "len" bytes is written even if the operation is successful.
+ */
static inline ssize_t xwrite(int fd, const void *buf, size_t len)
{
ssize_t nr;