{"thread":{"id":"13248","subject":"[PATCH] Document functions xmemdupz(), xread() and xwrite()","startedAt":"2008-04-24T23:58:23Z","lastAt":"2008-04-27T06:12:04Z","messageCount":2,"participants":["Heikki Orsila","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"75162","messageId":"20080424235823.GA22898@zakalwe.fi","threadId":"13248","inReplyTo":null,"subject":"[PATCH] Document functions xmemdupz(), xread() and xwrite()","fromName":"Heikki Orsila","fromEmail":"heikki.orsila@iki.fi","sentAt":"2008-04-24T23:58:23Z","receivedAt":"2008-04-24T23:58:23Z","isPatch":true,"sender":{"key":"heikki.orsila@iki.fi","avatar":null},"body":"Signed-off-by: Heikki Orsila <heikki.orsila@iki.fi>\n---\n git-compat-util.h |   14 ++++++++++++++\n 1 files changed, 14 insertions(+), 0 deletions(-)\n\ndiff --git a/git-compat-util.h b/git-compat-util.h\nindex a18235e..7498bee 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,9 @@ static inline ssize_t xread(int fd, void *buf, size_t len)\n \t}\n }\n \n+/*\n+ * xwrite() is similar to xread()\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"},{"id":"75261","messageId":"7viqy3j07f.fsf@gitster.siamese.dyndns.org","threadId":"13248","inReplyTo":"20080424235823.GA22898@zakalwe.fi","subject":"Re: [PATCH] Document functions xmemdupz(), xread() and xwrite()","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-04-27T06:12:04Z","receivedAt":"2008-04-27T06:12:04Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Heikki Orsila <heikki.orsila@iki.fi> writes:\n\n> Signed-off-by: Heikki Orsila <heikki.orsila@iki.fi>\n> ---\n>  git-compat-util.h |   14 ++++++++++++++\n>  1 files changed, 14 insertions(+), 0 deletions(-)\n>\n> diff --git a/git-compat-util.h b/git-compat-util.h\n> index a18235e..7498bee 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\nOk.\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\nOk.\n\n>  static inline ssize_t xread(int fd, void *buf, size_t len)\n>  {\n>  \tssize_t nr;\n> @@ -340,6 +351,9 @@ static inline ssize_t xread(int fd, void *buf, size_t len)\n>  \t}\n>  }\n>  \n> +/*\n> + * xwrite() is similar to xread()\n> + */\n\nWell, up to \"how recoverable errors are handled\" they may be similar but\nwould the last sentence apply to it as well, or does it need rewording?\n\n>  static inline ssize_t xwrite(int fd, const void *buf, size_t len)\n>  {\n>  \tssize_t nr;\n> -- \n> 1.5.4.4\n"}]}