File: strmcpy.c

package info (click to toggle)
ascd 0.7-2
  • links: PTS
  • area: main
  • in suites: hamm
  • size: 260 kB
  • ctags: 486
  • sloc: ansic: 5,262; makefile: 35
file content (28 lines) | stat: -rw-r--r-- 401 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <errno.h>
#include <stdio.h>
#include <sys/types.h>
#include <fcntl.h>
#include <sys/param.h>
#include <unistd.h>
#include <sys/time.h>
#include <ctype.h>
#include <sys/stat.h>  

/* Copy into a malloced string. */
void
strmcpy(t, s)
	char	**t, *s;
{
	if (*t != NULL)
		free(*t);

	*t = malloc(strlen(s) + 1);
	if (*t == NULL)
	{
		perror("strmcpy");
		exit(1);
	}

	(void) strcpy(*t, s);
}