File: strsave.c

package info (click to toggle)
seetex 2.19-9
  • links: PTS
  • area: main
  • in suites: woody
  • size: 1,460 kB
  • ctags: 2,909
  • sloc: ansic: 20,942; makefile: 807; sh: 217; lisp: 65; asm: 54; cpp: 17
file content (29 lines) | stat: -rw-r--r-- 587 bytes parent folder | download | duplicates (3)
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
29
/*
 * Copyright (c) 1987, 1989 University of Maryland
 * Department of Computer Science.  All rights reserved.
 * Permission to copy for any purpose is hereby granted
 * so long as this copyright notice remains intact.
 */

/*
 * Save a string in managed memory.
 */

char	*malloc(), *realloc();
extern int errno;

#include "types.h"		/* for bcopy */
#include "error.h"

char *
strsave(s)
	register char *s;
{
	register int l = strlen(s) + 1;
	register char *p = malloc((unsigned) l);

	if (p == 0)
		error(1, errno, "no room for %d bytes of string", l);
	bcopy(s, p, l);
	return (p);
}