Signed-off-by: Heikki Orsila <heikki.orsila@iki.fi>
---
git-compat-util.h | 14 ++++++++++++++
1 files changed, 14 insertions(+), 0 deletions(-)
diff --git a/git-compat-util.h b/git-compat-util.h
index a18235e..7498bee 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,9 @@ static inline ssize_t xread(int fd, void *buf, size_t len)
}
}
+/*
+ * xwrite() is similar to xread()
+ */
static inline ssize_t xwrite(int fd, const void *buf, size_t len)
{
ssize_t nr;
--
1.5.4.4
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
| david | Re: Dual-Licensing Linux Kernel with GPL V2 and GPL V3 |
| Natalie Protasevich | [BUG] New Kernel Bugs |
| Brice Goglin | Re: Linux 2.6.21-rc2 |
| Christian Volkmann | 2.6.23-rc6: usb 1-1: device not accepting address 2, error -62 |
git: | |
| Jon Smirl | Re: VCS comparison table |
| Nicolas Pitre | Re: git to libgit2 code relicensing |
| Giuseppe Bilotta | [PATCHv3 0/4] gitweb: remote heads feature |
| Mark Burton | Git commit won't add an untracked file given on the command line |
| Nick Guenther | Re: Real men don't attack straw men |
| Tanvir | Re: Adobe Flash on OpenBSD |
| Marius ROMAN | 1440x900 resolution problem |
| Gilles Chehade | Re: wpi (4) and 4.4 |
| Johann Baudy | Re: [PATCH] Packet socket: mmapped IO: PACKET_TX_RING |
| Volker Armin Hemmann | build error with 2.6.27.6+reiser4+ehci-hub patch. ERROR: "mii_ethtool_gset" [drive... |
| Patrick Ohly | [RFC PATCH 00/13] hardware time stamping + igb example implementation |
| Laszlo Attila Toth | [PATCHv7 3/5] Interface group: core (netlink) part |
