ReactOS  0.4.13-dev-73-gcfe54aa
Dynscat.c
Go to the documentation of this file.
1 #include <sys/types.h>
2 #include <stdlib.h>
3 #include <string.h>
4 #include <stdarg.h>
5 #include "Strn.h"
6 
7 /*VARARGS*/
8 char *
9 Dynscat(char **dst, ...)
10 {
11  va_list ap;
12  const char *src;
13  char *newdst, *dcp;
14  size_t curLen, catLen, srcLen;
15 
16  if (dst == (char **) 0)
17  return NULL;
18 
19  catLen = 0;
20  va_start(ap, dst);
21  src = va_arg(ap, char *);
22  while (src != NULL) {
23  catLen += strlen(src);
24  src = va_arg(ap, char *);
25  }
26  va_end(ap);
27 
28  if ((*dst == NULL) || (**dst == '\0'))
29  curLen = 0;
30  else
31  curLen = strlen(*dst);
32 
33  if (*dst == NULL)
34  newdst = malloc(curLen + catLen + 2);
35  else
36  newdst = realloc(*dst, curLen + catLen + 2);
37  if (newdst == NULL)
38  return NULL;
39 
40  dcp = newdst + curLen;
41  va_start(ap, dst);
42  src = va_arg(ap, char *);
43  while (src != NULL) {
44  srcLen = strlen(src);
45  memcpy(dcp, src, srcLen);
46  dcp += srcLen;
47  src = va_arg(ap, char *);
48  }
49  va_end(ap);
50  *dcp = '\0';
51 
52  *dst = newdst;
53  return (newdst);
54 } /* Dynscat */
#define realloc
Definition: debug_ros.c:6
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define va_end(ap)
Definition: acmsvcex.h:90
smooth NULL
Definition: ftsmooth.c:416
char * va_list
Definition: acmsvcex.h:78
char * Dynscat(char **dst,...)
Definition: Dynscat.c:9
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum src
Definition: glext.h:6340
#define va_arg(ap, T)
Definition: acmsvcex.h:89
GLenum GLenum dst
Definition: glext.h:6340
#define va_start(ap, A)
Definition: acmsvcex.h:91
void int int ULONGLONG int va_list * ap
Definition: winesup.h:32
#define malloc
Definition: debug_ros.c:4