---
 board3d/GLwidget.c | 38 +++++++-------------------------------
 1 file changed, 7 insertions(+), 31 deletions(-)

diff --git a/board3d/GLwidget.c b/board3d/GLwidget.c
index f788d896..deb4c5c1 100644
--- a/board3d/GLwidget.c
+++ b/board3d/GLwidget.c
@@ -186,39 +186,15 @@ void SelectPickProgram(void)
 
 static const char* LoadFile(const char* filename)
 {
-       long lSize;
-       char* buffer;
+    gchar *contents = NULL;
+    gsize length;
 
-       FILE* fp = fopen(filename, "rb");
-       if (!fp)
-       {
-               printf(_("Failed to open %s!\n"), filename);
-               return NULL;
-       }
-
-       fseek(fp, 0L, SEEK_END);
-       lSize = ftell(fp);
-       if (lSize == -1) {
-                fclose(fp);
-                return NULL;
-        }
-
-       if (fseek(fp, 0L, SEEK_SET) < 0) {
-               fclose(fp);
-               return NULL;
-       }
-
-       /* allocate memory for entire content */
-       buffer = calloc(1, lSize + 1);
-       if (!buffer) {
-                fclose(fp);
-                return NULL;
-        }
-
-       fread(buffer, lSize, 1, fp);
+    if (!g_file_get_contents(filename, &contents, &length, NULL)) {
+        g_print(_("Failed to open %s!\n"), filename);
+        return NULL;
+    }
 
-       fclose(fp);
-       return buffer;
+    return contents;
 }
 
 static guint CreateShader(int shader_type, const char* shader_name)
-- 
2.51.0


Reply via email to