}
/*
- * xnew, xrnew -- allocate, reallocate storage
+ * xrnew -- reallocate storage
*
- * SYNOPSIS: Type *xnew (ptrdiff_t n, Type);
- * void xrnew (OldPointer, ptrdiff_t n, int multiplier);
+ * SYNOPSIS: void xrnew (OldPointer, ptrdiff_t n, int multiplier);
*/
-#define xnew(n, Type) ((Type *) xnmalloc (n, sizeof (Type)))
#define xrnew(op, n, m) ((op) = xnrealloc (op, n, (m) * sizeof *(op)))
typedef void Lang_function (FILE *);
progname = argv[0];
nincluded_files = 0;
- included_files = xnew (argc, char *);
+ included_files = xnmalloc (argc, sizeof *included_files);
current_arg = 0;
file_count = 0;
/* Allocate enough no matter what happens. Overkill, but each one
is small. */
- argbuffer = xnew (argc, argument);
+ argbuffer = xnmalloc (argc, sizeof *argbuffer);
/*
* Always find typedefs and structure tags.
infilename = fn;
/* Create a new input file description entry. */
- fdp = xnew (1, fdesc);
+ fdp = xmalloc (sizeof *fdp);
*fdp = emptyfdesc;
fdp->next = fdhead;
fdp->infname = savestr (fn);
|| (!CTAGS && name && name[0] == '\0'))
return;
- np = xnew (1, node);
+ np = xmalloc (sizeof *np);
/* If ctags mode, change name "main" to M<thisfilename>. */
if (CTAGS && !cxref_style && streq (name, "main"))
{
if (np)
{
- stkentry *new = xnew (1, stkentry);
+ stkentry *new = xmalloc (sizeof *new);
new->np = np;
new->next = *stack_top;
{
cstack.size = (DEBUG) ? 1 : 4;
cstack.nl = 0;
- cstack.cname = xnew (cstack.size, char *);
- cstack.bracelev = xnew (cstack.size, ptrdiff_t);
+ cstack.cname = xnmalloc (cstack.size, sizeof *cstack.cname);
+ cstack.bracelev = xnmalloc (cstack.size, sizeof *cstack.bracelev);
}
tokoff = toklen = typdefbracelev = 0; /* keep compiler quiet */
if (writer)
{
size_t name_len = cp - np + 1;
- char *wr_name = xnew (name_len + 1, char);
+ char *wr_name = xmalloc (name_len + 1);
strcpy (mempcpy (wr_name, np, name_len - 1), "=");
pfnote (wr_name, true, lb.buffer, cp - lb.buffer + 1,
for (p = env; (p = strchr (p, ':')); )
if (*++p)
len++;
- TEX_toktab = xnew (len, linebuffer);
+ TEX_toktab = xnmalloc (len, sizeof *TEX_toktab);
/* Unpack environment string into token table. Be careful about */
/* zero-length strings (leading ':', "::" and trailing ':') */
break;
}
- patbuf = xnew (1, struct re_pattern_buffer);
+ patbuf = xmalloc (sizeof *patbuf);
*patbuf = zeropattern;
if (ignore_case)
{
}
rp = p_head;
- p_head = xnew (1, regexp);
+ p_head = xmalloc (sizeof *p_head);
p_head->pattern = savestr (regexp_pattern);
p_head->p_next = rp;
p_head->lang = lang;
/* Allocate space and do the substitutions. */
assert (size >= 0);
- result = xnew (size + 1, char);
+ result = xmalloc (size + 1);
for (t = result; *out != '\0'; out++)
if (*out == '\\' && c_isdigit (*++out))
if (fdp == NULL) /* not found */
{
fdp = fdhead;
- fdhead = xnew (1, fdesc);
+ fdhead = xmalloc (sizeof *fdhead);
*fdhead = *curfdp; /* copy curr. file description */
fdhead->next = fdp;
fdhead->infname = savestr (curfdp->infname);
\f
/*
* Return a pointer to a space of size strlen(cp)+1 allocated
- * with xnew where the string CP has been copied.
+ * with xmalloc where the string CP has been copied.
*/
static char *
savestr (const char *cp)
}
/*
- * Return a pointer to a space of size LEN+1 allocated with xnew
+ * Return a pointer to a space of size LEN+1 allocated with xmalloc
* with a copy of CP (containing LEN bytes) followed by a NUL byte.
*/
static char *
savenstr (const char *cp, ptrdiff_t len)
{
- char *dp = xnew (len + 1, char);
+ char *dp = xmalloc (len + 1);
dp[len] = '\0';
return memcpy (dp, cp, len);
}
concat (const char *s1, const char *s2, const char *s3)
{
ptrdiff_t len1 = strlen (s1), len2 = strlen (s2), len3 = strlen (s3);
- char *result = xnew (len1 + len2 + len3 + 1, char);
+ char *result = xmalloc (len1 + len2 + len3 + 1);
strcpy (stpcpy (stpcpy (result, s1), s2), s3);
return result;
}
etags_getcwd (void)
{
ptrdiff_t bufsize = 200;
- char *path = xnew (bufsize, char);
+ char *path = xmalloc (bufsize);
while (getcwd (path, bufsize) == NULL)
{
p++;
}
- char *new_str = xnew (need_space + 1, char);
+ char *new_str = xmalloc (need_space + 1);
new_str[0] = '\'';
new_str[need_space-1] = '\'';
i = 0;
while ((dp = strchr (dp + 1, '/')) != NULL)
i += 1;
- res = xnew (3*i + strlen (fp + 1) + 1, char);
+ res = xmalloc (3*i + strlen (fp + 1) + 1);
char *z = res;
while (i-- > 0)
z = stpcpy (z, "../");
linebuffer_init (linebuffer *lbp)
{
lbp->size = (DEBUG) ? 3 : 200;
- lbp->buffer = xnew (lbp->size, char);
+ lbp->buffer = xmalloc (lbp->size);
lbp->buffer[0] = '\0';
lbp->len = 0;
}