summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard W.M. Jones <rjones@redhat.com>2011-09-28 14:17:53 +0100
committerRichard W.M. Jones <rjones@redhat.com>2011-09-28 14:52:56 +0100
commitffc01285ee4289da90983a3320873f27b3d31c4d (patch)
treee267cf107202f27e3cebcc26734263dcfea92830
parent322106521f546d7c70c5a38255db7d243a456a6b (diff)
downloadlibguestfs-ffc01285ee4289da90983a3320873f27b3d31c4d.tar.gz
libguestfs-ffc01285ee4289da90983a3320873f27b3d31c4d.tar.xz
libguestfs-ffc01285ee4289da90983a3320873f27b3d31c4d.zip
daemon: Move useful is_zero function to header file.
Code motion.
-rw-r--r--daemon/daemon.h18
-rw-r--r--daemon/zero.c18
2 files changed, 18 insertions, 18 deletions
diff --git a/daemon/daemon.h b/daemon/daemon.h
index 77ee6281..b4f99a81 100644
--- a/daemon/daemon.h
+++ b/daemon/daemon.h
@@ -191,6 +191,24 @@ extern void pulse_mode_start (void);
extern void pulse_mode_end (void);
extern void pulse_mode_cancel (void);
+/* Return true iff the buffer is all zero bytes.
+ *
+ * Note that gcc is smart enough to optimize this properly:
+ * http://stackoverflow.com/questions/1493936/faster-means-of-checking-for-an-empty-buffer-in-c/1493989#1493989
+ */
+static inline int
+is_zero (const char *buffer, size_t size)
+{
+ size_t i;
+
+ for (i = 0; i < size; ++i) {
+ if (buffer[i] != 0)
+ return 0;
+ }
+
+ return 1;
+}
+
/* Helper for functions that need a root filesystem mounted.
* NB. Cannot be used for FileIn functions.
*/
diff --git a/daemon/zero.c b/daemon/zero.c
index c9f6bf7f..8df2298c 100644
--- a/daemon/zero.c
+++ b/daemon/zero.c
@@ -28,24 +28,6 @@
#include "daemon.h"
#include "actions.h"
-/* Return true iff the buffer is all zero bytes.
- *
- * Note that gcc is smart enough to optimize this properly:
- * http://stackoverflow.com/questions/1493936/faster-means-of-checking-for-an-empty-buffer-in-c/1493989#1493989
- */
-static int
-is_zero (const char *buffer, size_t size)
-{
- size_t i;
-
- for (i = 0; i < size; ++i) {
- if (buffer[i] != 0)
- return 0;
- }
-
- return 1;
-}
-
static const char zero_buf[4096];
int