Signed-off-by: Pierre Habouzit <madcoder@debian.org>
static int read_material (size_t material, size_t * used, FILE * fp)
{
if (*used + material >= plen) {
static int read_material (size_t material, size_t * used, FILE * fp)
{
if (*used + material >= plen) {
- unsigned char *p;
- size_t nplen;
-
- nplen = *used + material + CHUNKSIZE;
-
- if (!(p = realloc(pbuf, nplen))) {
- perror ("realloc");
- return -1;
- }
- plen = nplen;
- pbuf = p;
+ p_realloc(&pbuf, plen = *used + material + CHUNKSIZE);
}
if (fread (pbuf + *used, 1, material, fp) < material) {
}
if (fread (pbuf + *used, 1, material, fp) < material) {
static void add_var (const char *name)
{
static void add_var (const char *name)
{
- outbuf = realloc (outbuf, (++outcount) * sizeof (var_t));
+ p_realloc(&outbuf, ++outcount);
outbuf[outcount - 1].seen = 0;
outbuf[outcount - 1].name = strdup(name);
outbuf[outcount - 1].descr = NULL;
outbuf[outcount - 1].seen = 0;
outbuf[outcount - 1].name = strdup(name);
outbuf[outcount - 1].descr = NULL;
if (lold == 0)
outbuf[outcount - 1].descr = strdup(s);
else {
if (lold == 0)
outbuf[outcount - 1].descr = strdup(s);
else {
- outbuf[outcount - 1].descr =
- realloc (outbuf[outcount - 1].descr, lold + lnew + 1);
- memcpy (&(outbuf[outcount - 1].descr[lold - 1]) + 1, s, lnew);
+ p_realloc(&outbuf[outcount - 1].descr, lold + lnew + 1);
+ memcpy(&(outbuf[outcount - 1].descr[lold - 1]) + 1, s, lnew);
}
outbuf[outcount - 1].descr[lold + lnew] = '\0';
return (1);
}
outbuf[outcount - 1].descr[lold + lnew] = '\0';
return (1);
for (line = 0; line < outcount; line++) {
if (outbuf[line].descr) {
fprintf (out, "%s\n", outbuf[line].descr);
for (line = 0; line < outcount; line++) {
if (outbuf[line].descr) {
fprintf (out, "%s\n", outbuf[line].descr);
- free (outbuf[line].descr);
+ p_delete(&outbuf[line].descr);
- free (outbuf[line].name);
+ p_delete(&outbuf[line].name);
print_confline (varname, type, val);
}
print_confline (varname, type, val);
}
-static void char_to_escape (char *dest, unsigned int c)
+static void char_to_escape (char *dest, int len, unsigned int c)
{
switch (c) {
case '\r':
{
switch (c) {
case '\r':
+ m_strcpy(dest, len, "\\r");
+ m_strcpy(dest, len, "\\n");
+ m_strcpy(dest, len, "\\t");
+ m_strcpy(dest, len, "\\f");
- sprintf (dest, "\\%03o", c);
+ sprintf (dest, len, "\\%03o", c);
- char_to_escape (buff, c);
+ char_to_escape(buff, sizeof(buff), c);
for (; *v; v++) {
if (*v < ' ' || *v & 0x80) {
for (; *v; v++) {
if (*v < ' ' || *v & 0x80) {
- char_to_escape (buff, (unsigned int) *v);
+ char_to_escape(buff, sizeof(buff), (unsigned int) *v);
sgml_fputs (buff);
continue;
}
sgml_fputs (buff);
continue;
}
int octets;
if (*buf == NULL)
int octets;
if (*buf == NULL)
- *buf = malloc (BUFLEN);
+ *buf = xmalloc(BUFLEN);
if (len == NULL) {
rewind ((FILE *) arg);
if (len == NULL) {
rewind ((FILE *) arg);