{"thread":{"id":"13280","subject":"[PATCH] Document functions xmemdupz(), xread() and xwrite()","startedAt":"2008-04-27T09:48:30Z","lastAt":"2008-04-27T09:48:30Z","messageCount":1,"participants":["Heikki Orsila"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"75281","messageId":"20080427094830.GA23670@zakalwe.fi","threadId":"13280","inReplyTo":null,"subject":"[PATCH] Document functions xmemdupz(), xread() and xwrite()","fromName":"Heikki Orsila","fromEmail":"heikki.orsila@iki.fi","sentAt":"2008-04-27T09:48:30Z","receivedAt":"2008-04-27T09:48:30Z","isPatch":true,"sender":{"key":"heikki.orsila@iki.fi","avatar":null},"body":"Signed-off-by: Heikki Orsila <heikki.orsila@iki.fi>\n---\nThis is version 2 of the documentation patch. Compared to version 1,\nxwrite() behavior is documented explicitly.\n\n git-compat-util.h |   16 ++++++++++++++++\n 1 files changed, 16 insertions(+), 0 deletions(-)\n\ndiff --git a/git-compat-util.h b/git-compat-util.h\nindex a18235e..167c3fe 100644\n--- a/git-compat-util.h\n+++ b/git-compat-util.h\n@@ -268,6 +268,12 @@ static inline void *xmalloc(size_t size)\n \treturn ret;\n }\n \n+/*\n+ * xmemdupz() allocates (len + 1) bytes of memory, duplicates \"len\" bytes of\n+ * \"data\" to the allocated memory, zero terminates the allocated memory,\n+ * and returns a pointer to the allocated memory. If the allocation fails,\n+ * the program dies.\n+ */\n static inline void *xmemdupz(const void *data, size_t len)\n {\n \tchar *p = xmalloc(len + 1);\n@@ -329,6 +335,11 @@ static inline void *xmmap(void *start, size_t length,\n \treturn ret;\n }\n \n+/*\n+ * xread() is the same a read(), but it automatically restarts read()\n+ * operations with a recoverable error (EAGAIN and EINTR). xread()\n+ * DOES NOT GUARANTEE that \"len\" bytes is read even if the data is available.\n+ */\n static inline ssize_t xread(int fd, void *buf, size_t len)\n {\n \tssize_t nr;\n@@ -340,6 +351,11 @@ static inline ssize_t xread(int fd, void *buf, size_t len)\n \t}\n }\n \n+/*\n+ * xwrite() is the same a write(), but it automatically restarts write()\n+ * operations with a recoverable error (EAGAIN and EINTR). xwrite() DOES NOT\n+ * GUARANTEE that \"len\" bytes is written even if the operation is successful.\n+ */\n static inline ssize_t xwrite(int fd, const void *buf, size_t len)\n {\n \tssize_t nr;\n-- \n1.5.4.4\n"}]}