From 98d552e0cd0479ec373055eefc11716d2927936e Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Thu, 28 Dec 2006 04:48:06 +0000 Subject: [PATCH] Consistently use gsize rather than size_t. (#333310, Morten Welinder) 2006-12-27 Matthias Clasen * glib/gconvert.[hc]: * glib/gfileutils.c: * glib/giochannel.c: * glib/goption.c: * glib/gspawn.c: * glib/gunicollate.c: * glib/gutils.c: * tests/timeloop-basic.c: Consistently use gsize rather than size_t. (#333310, Morten Welinder) --- ChangeLog | 13 +++++++++++++ glib/gconvert.c | 12 ++++++------ glib/gconvert.h | 3 +-- glib/gfileutils.c | 14 +++++++------- glib/giochannel.c | 18 +++++++++--------- glib/gspawn.c | 4 ++-- glib/gunicollate.c | 10 +++++----- glib/gutils.c | 4 ++-- tests/timeloop-basic.c | 8 ++++---- 9 files changed, 49 insertions(+), 37 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1124095..4989fc2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,18 @@ 2006-12-27 Matthias Clasen + * glib/gconvert.[hc]: + * glib/gfileutils.c: + * glib/giochannel.c: + * glib/goption.c: + * glib/gspawn.c: + * glib/gunicollate.c: + * glib/gutils.c: + * tests/timeloop-basic.c: + Consistently use gsize rather than size_t. (#333310, + Morten Welinder) + +2006-12-27 Matthias Clasen + * configure.in: Use AC_CACHE_CHECK for the nl_langinfo check. (#304517, Lőrinczy Zsigmond) diff --git a/glib/gconvert.c b/glib/gconvert.c index dcc798b..4c25674 100644 --- a/glib/gconvert.c +++ b/glib/gconvert.c @@ -157,7 +157,7 @@ g_iconv_open (const gchar *to_codeset, * * Return value: count of non-reversible conversions, or -1 on error **/ -size_t +gsize g_iconv (GIConv converter, gchar **inbuf, gsize *inbytes_left, @@ -596,7 +596,7 @@ g_convert_with_iconv (const gchar *str, { err = g_iconv (converter, (char **)&p, &inbytes_remaining, &outp, &outbytes_remaining); - if (err == (size_t) -1) + if (err == (gsize) -1) { switch (errno) { @@ -606,7 +606,7 @@ g_convert_with_iconv (const gchar *str, break; case E2BIG: { - size_t used = outp - dest; + gsize used = outp - dest; outbuf_size *= 2; dest = g_realloc (dest, outbuf_size); @@ -880,11 +880,11 @@ g_convert_with_fallback (const gchar *str, while (!done && !have_error) { - size_t inbytes_tmp = inbytes_remaining; + gsize inbytes_tmp = inbytes_remaining; err = g_iconv (cd, (char **)&p, &inbytes_tmp, &outp, &outbytes_remaining); inbytes_remaining = inbytes_tmp; - if (err == (size_t) -1) + if (err == (gsize) -1) { switch (errno) { @@ -893,7 +893,7 @@ g_convert_with_fallback (const gchar *str, break; case E2BIG: { - size_t used = outp - dest; + gsize used = outp - dest; outbuf_size *= 2; dest = g_realloc (dest, outbuf_size); diff --git a/glib/gconvert.h b/glib/gconvert.h index 90dc212..9e6ca65 100644 --- a/glib/gconvert.h +++ b/glib/gconvert.h @@ -27,7 +27,6 @@ #ifndef __G_CONVERT_H__ #define __G_CONVERT_H__ -#include /* For size_t */ #include G_BEGIN_DECLS @@ -51,7 +50,7 @@ typedef struct _GIConv *GIConv; GIConv g_iconv_open (const gchar *to_codeset, const gchar *from_codeset); -size_t g_iconv (GIConv converter, +gsize g_iconv (GIConv converter, gchar **inbuf, gsize *inbytes_left, gchar **outbuf, diff --git a/glib/gfileutils.c b/glib/gfileutils.c index c19caa8..7c271bb 100644 --- a/glib/gfileutils.c +++ b/glib/gfileutils.c @@ -525,10 +525,10 @@ get_contents_stdio (const gchar *display_filename, GError **error) { gchar buf[4096]; - size_t bytes; + gsize bytes; gchar *str = NULL; - size_t total_bytes = 0; - size_t total_allocated = 0; + gsize total_bytes = 0; + gsize total_allocated = 0; gchar *tmp; g_assert (f != NULL); @@ -613,9 +613,9 @@ get_contents_regfile (const gchar *display_filename, GError **error) { gchar *buf; - size_t bytes_read; - size_t size; - size_t alloc_size; + gsize bytes_read; + gsize size; + gsize alloc_size; size = stat_buf->st_size; @@ -954,7 +954,7 @@ write_to_temp_file (const gchar *contents, if (length > 0) { - size_t n_written; + gsize n_written; errno = 0; diff --git a/glib/giochannel.c b/glib/giochannel.c index 49d7cb3..42fcec2 100644 --- a/glib/giochannel.c +++ b/glib/giochannel.c @@ -1263,7 +1263,7 @@ g_io_channel_fill_buffer (GIOChannel *channel, if (channel->do_encode) { - size_t errnum, inbytes_left, outbytes_left; + gsize errnum, inbytes_left, outbytes_left; gchar *inbuf, *outbuf; int errval; @@ -1297,7 +1297,7 @@ reencode: g_string_truncate (channel->encoded_read_buf, channel->encoded_read_buf->len - outbytes_left); - if (errnum == (size_t) -1) + if (errnum == (gsize) -1) { switch (errval) { @@ -2055,7 +2055,7 @@ g_io_channel_write_chars (GIOChannel *channel, { const gchar *from_buf; gsize from_buf_len, from_buf_old_len, left_len; - size_t err; + gsize err; gint errnum; if (channel->partial_write_buf[0] != '\0') @@ -2102,29 +2102,29 @@ reconvert: if (try_len == from_buf_len) { errnum = EINVAL; - err = (size_t) -1; + err = (gsize) -1; } else { errnum = 0; - err = (size_t) 0; + err = (gsize) 0; } break; case -1: g_warning ("Invalid UTF-8 passed to g_io_channel_write_chars()."); /* FIXME bail here? */ errnum = EILSEQ; - err = (size_t) -1; + err = (gsize) -1; break; default: g_assert_not_reached (); - err = (size_t) -1; + err = (gsize) -1; errnum = 0; /* Don't confunse the compiler */ } } else { - err = (size_t) 0; + err = (gsize) 0; errnum = 0; left_len = from_buf_len - try_len; } @@ -2149,7 +2149,7 @@ reconvert: - space_in_buf); } - if (err == (size_t) -1) + if (err == (gsize) -1) { switch (errnum) { diff --git a/glib/gspawn.c b/glib/gspawn.c index 2cd8cc1..34ab02f 100644 --- a/glib/gspawn.c +++ b/glib/gspawn.c @@ -1476,8 +1476,8 @@ g_execute (const gchar *file, gboolean got_eacces = 0; const gchar *path, *p; gchar *name, *freeme; - size_t len; - size_t pathlen; + gsize len; + gsize pathlen; path = g_getenv ("PATH"); if (path == NULL) diff --git a/glib/gunicollate.c b/glib/gunicollate.c index 959c7ee..5feec5a 100644 --- a/glib/gunicollate.c +++ b/glib/gunicollate.c @@ -32,10 +32,10 @@ #ifdef _MSC_VER /* Workaround for bug in MSVCR80.DLL */ -static size_t +static gsize msc_strxfrm_wrapper (char *string1, const char *string2, - size_t count) + gsize count) { if (!string1 || count <= 0) { @@ -200,14 +200,14 @@ g_utf8_collate_key (const gchar *str, gssize len) { gchar *result; - size_t xfrm_len; + gsize xfrm_len; #ifdef __STDC_ISO_10646__ gunichar *str_norm; wchar_t *result_wc; - size_t i; - size_t result_len = 0; + gsize i; + gsize result_len = 0; g_return_val_if_fail (str != NULL, NULL); diff --git a/glib/gutils.c b/glib/gutils.c index 72d9b68..1eee8b2 100644 --- a/glib/gutils.c +++ b/glib/gutils.c @@ -391,8 +391,8 @@ g_find_program_in_path (const gchar *program) wchar_t wfilename[MAXPATHLEN], wsysdir[MAXPATHLEN], wwindir[MAXPATHLEN]; #endif - size_t len; - size_t pathlen; + gsize len; + gsize pathlen; g_return_val_if_fail (program != NULL, NULL); diff --git a/tests/timeloop-basic.c b/tests/timeloop-basic.c index 56861f3..6ca291d 100644 --- a/tests/timeloop-basic.c +++ b/tests/timeloop-basic.c @@ -33,8 +33,8 @@ my_pipe (int *fds) int read_all (int fd, char *buf, int len) { - size_t bytes_read = 0; - ssize_t count; + gsize bytes_read = 0; + gssize count; while (bytes_read < len) { @@ -56,8 +56,8 @@ read_all (int fd, char *buf, int len) int write_all (int fd, char *buf, int len) { - size_t bytes_written = 0; - ssize_t count; + gsize bytes_written = 0; + gssize count; while (bytes_written < len) { -- 2.7.4