[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
C++ support (4)
From: |
Bruno Haible |
Subject: |
C++ support (4) |
Date: |
Tue, 31 Oct 2006 20:21:57 +0100 |
User-agent: |
KMail/1.9.1 |
The other change requires to add casts for xmalloc calls, and to move the
'struct slotvec' outside the function where it's currently defined - otherwise
it is not a valid template parameter for the xrealloc template (and without
the xrealloc template, one needs to add dozens of casts).
Paul, what do you think?
*** gnulib-20061026/lib/quotearg.c 2006-10-07 01:01:48.000000000 +0200
--- gnulib-20061026-modified/lib/quotearg.c 2006-10-29 23:46:27.000000000
+0100
***************
*** 122,128 ****
clone_quoting_options (struct quoting_options *o)
{
int e = errno;
! struct quoting_options *p = xmalloc (sizeof *p);
*p = *(o ? o : &default_quoting_options);
errno = e;
return p;
--- 122,128 ----
clone_quoting_options (struct quoting_options *o)
{
int e = errno;
! struct quoting_options *p = (struct quoting_options *) xmalloc (sizeof *p);
*p = *(o ? o : &default_quoting_options);
errno = e;
return p;
***************
*** 554,565 ****
{
int e = errno;
size_t bufsize = quotearg_buffer (0, 0, arg, argsize, o) + 1;
! char *buf = xmalloc (bufsize);
quotearg_buffer (buf, bufsize, arg, argsize, o);
errno = e;
return buf;
}
/* Use storage slot N to return a quoted version of argument ARG.
ARG is of size ARGSIZE, but if that is SIZE_MAX, ARG is a
null-terminated string.
--- 554,571 ----
{
int e = errno;
size_t bufsize = quotearg_buffer (0, 0, arg, argsize, o) + 1;
! char *buf = (char *) xmalloc (bufsize);
quotearg_buffer (buf, bufsize, arg, argsize, o);
errno = e;
return buf;
}
+ struct slotvec
+ {
+ size_t size;
+ char *val;
+ };
+
/* Use storage slot N to return a quoted version of argument ARG.
ARG is of size ARGSIZE, but if that is SIZE_MAX, ARG is a
null-terminated string.
***************
*** 579,589 ****
static char slot0[256];
static unsigned int nslots = 1;
unsigned int n0 = n;
- struct slotvec
- {
- size_t size;
- char *val;
- };
static struct slotvec slotvec0 = {sizeof slot0, slot0};
static struct slotvec *slotvec = &slotvec0;
--- 585,590 ----
***************
*** 604,610 ****
if (slotvec == &slotvec0)
{
! slotvec = xmalloc (sizeof *slotvec);
*slotvec = slotvec0;
}
slotvec = xrealloc (slotvec, n1 * sizeof *slotvec);
--- 605,611 ----
if (slotvec == &slotvec0)
{
! slotvec = (struct slotvec *) xmalloc (sizeof *slotvec);
*slotvec = slotvec0;
}
slotvec = xrealloc (slotvec, n1 * sizeof *slotvec);
***************
*** 622,628 ****
slotvec[n].size = size = qsize + 1;
if (val != slot0)
free (val);
! slotvec[n].val = val = xmalloc (size);
quotearg_buffer (val, size, arg, argsize, options);
}
--- 623,629 ----
slotvec[n].size = size = qsize + 1;
if (val != slot0)
free (val);
! slotvec[n].val = val = (char *) xmalloc (size);
quotearg_buffer (val, size, arg, argsize, options);
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- C++ support (4),
Bruno Haible <=