Consistently use gsize rather than size_t. (#333310, Morten Welinder)

2006-12-27  Matthias Clasen  <mclasen@redhat.com>

        * 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)
This commit is contained in:
Matthias Clasen
2006-12-28 04:48:06 +00:00
committed by Matthias Clasen
parent f678ea9725
commit 98d552e0cd
9 changed files with 49 additions and 37 deletions

View File

@@ -1,3 +1,16 @@
2006-12-27 Matthias Clasen <mclasen@redhat.com>
* 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 <mclasen@redhat.com> 2006-12-27 Matthias Clasen <mclasen@redhat.com>
* configure.in: Use AC_CACHE_CHECK for the nl_langinfo * configure.in: Use AC_CACHE_CHECK for the nl_langinfo

View File

@@ -157,7 +157,7 @@ g_iconv_open (const gchar *to_codeset,
* *
* Return value: count of non-reversible conversions, or -1 on error * Return value: count of non-reversible conversions, or -1 on error
**/ **/
size_t gsize
g_iconv (GIConv converter, g_iconv (GIConv converter,
gchar **inbuf, gchar **inbuf,
gsize *inbytes_left, 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); err = g_iconv (converter, (char **)&p, &inbytes_remaining, &outp, &outbytes_remaining);
if (err == (size_t) -1) if (err == (gsize) -1)
{ {
switch (errno) switch (errno)
{ {
@@ -606,7 +606,7 @@ g_convert_with_iconv (const gchar *str,
break; break;
case E2BIG: case E2BIG:
{ {
size_t used = outp - dest; gsize used = outp - dest;
outbuf_size *= 2; outbuf_size *= 2;
dest = g_realloc (dest, outbuf_size); dest = g_realloc (dest, outbuf_size);
@@ -880,11 +880,11 @@ g_convert_with_fallback (const gchar *str,
while (!done && !have_error) 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); err = g_iconv (cd, (char **)&p, &inbytes_tmp, &outp, &outbytes_remaining);
inbytes_remaining = inbytes_tmp; inbytes_remaining = inbytes_tmp;
if (err == (size_t) -1) if (err == (gsize) -1)
{ {
switch (errno) switch (errno)
{ {
@@ -893,7 +893,7 @@ g_convert_with_fallback (const gchar *str,
break; break;
case E2BIG: case E2BIG:
{ {
size_t used = outp - dest; gsize used = outp - dest;
outbuf_size *= 2; outbuf_size *= 2;
dest = g_realloc (dest, outbuf_size); dest = g_realloc (dest, outbuf_size);

View File

@@ -27,7 +27,6 @@
#ifndef __G_CONVERT_H__ #ifndef __G_CONVERT_H__
#define __G_CONVERT_H__ #define __G_CONVERT_H__
#include <stddef.h> /* For size_t */
#include <glib/gerror.h> #include <glib/gerror.h>
G_BEGIN_DECLS G_BEGIN_DECLS
@@ -51,7 +50,7 @@ typedef struct _GIConv *GIConv;
GIConv g_iconv_open (const gchar *to_codeset, GIConv g_iconv_open (const gchar *to_codeset,
const gchar *from_codeset); const gchar *from_codeset);
size_t g_iconv (GIConv converter, gsize g_iconv (GIConv converter,
gchar **inbuf, gchar **inbuf,
gsize *inbytes_left, gsize *inbytes_left,
gchar **outbuf, gchar **outbuf,

View File

@@ -525,10 +525,10 @@ get_contents_stdio (const gchar *display_filename,
GError **error) GError **error)
{ {
gchar buf[4096]; gchar buf[4096];
size_t bytes; gsize bytes;
gchar *str = NULL; gchar *str = NULL;
size_t total_bytes = 0; gsize total_bytes = 0;
size_t total_allocated = 0; gsize total_allocated = 0;
gchar *tmp; gchar *tmp;
g_assert (f != NULL); g_assert (f != NULL);
@@ -613,9 +613,9 @@ get_contents_regfile (const gchar *display_filename,
GError **error) GError **error)
{ {
gchar *buf; gchar *buf;
size_t bytes_read; gsize bytes_read;
size_t size; gsize size;
size_t alloc_size; gsize alloc_size;
size = stat_buf->st_size; size = stat_buf->st_size;
@@ -954,7 +954,7 @@ write_to_temp_file (const gchar *contents,
if (length > 0) if (length > 0)
{ {
size_t n_written; gsize n_written;
errno = 0; errno = 0;

View File

@@ -1263,7 +1263,7 @@ g_io_channel_fill_buffer (GIOChannel *channel,
if (channel->do_encode) if (channel->do_encode)
{ {
size_t errnum, inbytes_left, outbytes_left; gsize errnum, inbytes_left, outbytes_left;
gchar *inbuf, *outbuf; gchar *inbuf, *outbuf;
int errval; int errval;
@@ -1297,7 +1297,7 @@ reencode:
g_string_truncate (channel->encoded_read_buf, g_string_truncate (channel->encoded_read_buf,
channel->encoded_read_buf->len - outbytes_left); channel->encoded_read_buf->len - outbytes_left);
if (errnum == (size_t) -1) if (errnum == (gsize) -1)
{ {
switch (errval) switch (errval)
{ {
@@ -2055,7 +2055,7 @@ g_io_channel_write_chars (GIOChannel *channel,
{ {
const gchar *from_buf; const gchar *from_buf;
gsize from_buf_len, from_buf_old_len, left_len; gsize from_buf_len, from_buf_old_len, left_len;
size_t err; gsize err;
gint errnum; gint errnum;
if (channel->partial_write_buf[0] != '\0') if (channel->partial_write_buf[0] != '\0')
@@ -2102,29 +2102,29 @@ reconvert:
if (try_len == from_buf_len) if (try_len == from_buf_len)
{ {
errnum = EINVAL; errnum = EINVAL;
err = (size_t) -1; err = (gsize) -1;
} }
else else
{ {
errnum = 0; errnum = 0;
err = (size_t) 0; err = (gsize) 0;
} }
break; break;
case -1: case -1:
g_warning ("Invalid UTF-8 passed to g_io_channel_write_chars()."); g_warning ("Invalid UTF-8 passed to g_io_channel_write_chars().");
/* FIXME bail here? */ /* FIXME bail here? */
errnum = EILSEQ; errnum = EILSEQ;
err = (size_t) -1; err = (gsize) -1;
break; break;
default: default:
g_assert_not_reached (); g_assert_not_reached ();
err = (size_t) -1; err = (gsize) -1;
errnum = 0; /* Don't confunse the compiler */ errnum = 0; /* Don't confunse the compiler */
} }
} }
else else
{ {
err = (size_t) 0; err = (gsize) 0;
errnum = 0; errnum = 0;
left_len = from_buf_len - try_len; left_len = from_buf_len - try_len;
} }
@@ -2149,7 +2149,7 @@ reconvert:
- space_in_buf); - space_in_buf);
} }
if (err == (size_t) -1) if (err == (gsize) -1)
{ {
switch (errnum) switch (errnum)
{ {

View File

@@ -1476,8 +1476,8 @@ g_execute (const gchar *file,
gboolean got_eacces = 0; gboolean got_eacces = 0;
const gchar *path, *p; const gchar *path, *p;
gchar *name, *freeme; gchar *name, *freeme;
size_t len; gsize len;
size_t pathlen; gsize pathlen;
path = g_getenv ("PATH"); path = g_getenv ("PATH");
if (path == NULL) if (path == NULL)

View File

@@ -32,10 +32,10 @@
#ifdef _MSC_VER #ifdef _MSC_VER
/* Workaround for bug in MSVCR80.DLL */ /* Workaround for bug in MSVCR80.DLL */
static size_t static gsize
msc_strxfrm_wrapper (char *string1, msc_strxfrm_wrapper (char *string1,
const char *string2, const char *string2,
size_t count) gsize count)
{ {
if (!string1 || count <= 0) if (!string1 || count <= 0)
{ {
@@ -200,14 +200,14 @@ g_utf8_collate_key (const gchar *str,
gssize len) gssize len)
{ {
gchar *result; gchar *result;
size_t xfrm_len; gsize xfrm_len;
#ifdef __STDC_ISO_10646__ #ifdef __STDC_ISO_10646__
gunichar *str_norm; gunichar *str_norm;
wchar_t *result_wc; wchar_t *result_wc;
size_t i; gsize i;
size_t result_len = 0; gsize result_len = 0;
g_return_val_if_fail (str != NULL, NULL); g_return_val_if_fail (str != NULL, NULL);

View File

@@ -391,8 +391,8 @@ g_find_program_in_path (const gchar *program)
wchar_t wfilename[MAXPATHLEN], wsysdir[MAXPATHLEN], wchar_t wfilename[MAXPATHLEN], wsysdir[MAXPATHLEN],
wwindir[MAXPATHLEN]; wwindir[MAXPATHLEN];
#endif #endif
size_t len; gsize len;
size_t pathlen; gsize pathlen;
g_return_val_if_fail (program != NULL, NULL); g_return_val_if_fail (program != NULL, NULL);

View File

@@ -33,8 +33,8 @@ my_pipe (int *fds)
int int
read_all (int fd, char *buf, int len) read_all (int fd, char *buf, int len)
{ {
size_t bytes_read = 0; gsize bytes_read = 0;
ssize_t count; gssize count;
while (bytes_read < len) while (bytes_read < len)
{ {
@@ -56,8 +56,8 @@ read_all (int fd, char *buf, int len)
int int
write_all (int fd, char *buf, int len) write_all (int fd, char *buf, int len)
{ {
size_t bytes_written = 0; gsize bytes_written = 0;
ssize_t count; gssize count;
while (bytes_written < len) while (bytes_written < len)
{ {