[gtkmm/gtkmm-3-22] gtk-demo/demowindow: Use size_t to index in arrays
- From: Daniel Boles <dboles src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtkmm/gtkmm-3-22] gtk-demo/demowindow: Use size_t to index in arrays
- Date: Fri, 26 May 2017 16:31:08 +0000 (UTC)
commit fbf695aabd92c70ba4d279b9f3bd0229cf05fedd
Author: Daniel Boles <dboles src gmail com>
Date: Fri May 26 17:20:15 2017 +0100
gtk-demo/demowindow: Use size_t to index in arrays
int or unsigned int are not guaranteed to be wide enough. Of course,
that will not matter in many practical cases, but it is better style to
always use std::size_t when the purpose is to index into an array.
demos/gtk-demo/demowindow.cc | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)
---
diff --git a/demos/gtk-demo/demowindow.cc b/demos/gtk-demo/demowindow.cc
index 47dac2f..53af9c3 100644
--- a/demos/gtk-demo/demowindow.cc
+++ b/demos/gtk-demo/demowindow.cc
@@ -29,6 +29,7 @@
#include "demos.h"
#include <iostream>
#include <cstring>
+#include <cstddef>
using std::isspace;
using std::strlen;
@@ -257,7 +258,7 @@ void DemoWindow::load_file(const std::string& filename)
int state = 0;
bool in_para = false;
auto start = refBufferInfo->get_iter_at_offset(0);
- for (int i = 0; lines[i] != NULL; i++)
+ for (std::size_t i = 0; lines[i] != NULL; i++)
{
/* Make sure \r is stripped at the end for the poor windows people */
lines[i] = g_strchomp(lines[i]);
@@ -382,7 +383,7 @@ void DemoWindow::add_data_tabs(const std::string& filename)
{
// Ignore this exception. It's no error, if resource_dir does not exist.
}
- for (unsigned int i = 0; i < resources.size(); ++i)
+ for (std::size_t i = 0; i < resources.size(); ++i)
{
const std::string resource_name = resource_dir + "/" + resources[i];
Gtk::Widget* widget = nullptr;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]