[gnome-builder] posix: use posix helper to get system page size



commit a085d131013092f5ad40e580db87d789f44fc861
Author: Christian Hergert <chergert redhat com>
Date:   Wed Feb 24 21:48:52 2016 -0800

    posix: use posix helper to get system page size

 libide/ide-highlight-index.c |    6 ++----
 libide/util/ide-posix.c      |    9 +++++++++
 libide/util/ide-posix.h      |    3 ++-
 3 files changed, 13 insertions(+), 5 deletions(-)
---
diff --git a/libide/ide-highlight-index.c b/libide/ide-highlight-index.c
index c7be3be..64f58eb 100644
--- a/libide/ide-highlight-index.c
+++ b/libide/ide-highlight-index.c
@@ -19,14 +19,12 @@
 #define G_LOG_DOMAIN "ide-highlight-index"
 
 #include <string.h>
-#include <sys/types.h>
-#include <sys/user.h>
-#include <unistd.h>
 
 #include "egg-counter.h"
 
 #include "ide-debug.h"
 #include "ide-highlight-index.h"
+#include "ide-posix.h"
 
 G_DEFINE_BOXED_TYPE (IdeHighlightIndex, ide_highlight_index,
                      ide_highlight_index_ref, ide_highlight_index_unref)
@@ -52,7 +50,7 @@ ide_highlight_index_new (void)
 
   ret = g_new0 (IdeHighlightIndex, 1);
   ret->ref_count = 1;
-  ret->strings = g_string_chunk_new (sysconf (_SC_PAGE_SIZE));
+  ret->strings = g_string_chunk_new (ide_get_system_page_size ());
   ret->index = g_hash_table_new (g_str_hash, g_str_equal);
 
   EGG_COUNTER_INC (instances);
diff --git a/libide/util/ide-posix.c b/libide/util/ide-posix.c
index f15ca39..ef4c9bb 100644
--- a/libide/util/ide-posix.c
+++ b/libide/util/ide-posix.c
@@ -17,7 +17,10 @@
  */
 
 #include <string.h>
+#include <sys/types.h>
+#include <sys/user.h>
 #include <sys/utsname.h>
+#include <unistd.h>
 
 #include "ide-posix.h"
 
@@ -35,3 +38,9 @@ ide_get_system_arch (void)
 
   return g_strdup (machine);
 }
+
+gsize
+ide_get_system_page_size (void)
+{
+  return sysconf (_SC_PAGE_SIZE);
+}
diff --git a/libide/util/ide-posix.h b/libide/util/ide-posix.h
index 193d60f..438774a 100644
--- a/libide/util/ide-posix.h
+++ b/libide/util/ide-posix.h
@@ -23,7 +23,8 @@
 
 G_BEGIN_DECLS
 
-gchar *ide_get_system_arch (void);
+gchar *ide_get_system_arch      (void);
+gsize  ide_get_system_page_size (void) G_GNUC_CONST;
 
 G_END_DECLS
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]