summaryrefslogtreecommitdiff
path: root/lexer/misc.c
blob: 9014421d8b365589e22aa6f8d8b599f5db26bdc4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
/* Name: cnvstr()
 * Desc: Converts a pointer, and length pair into a null-terminated string.
 * Args:
 *	s: Pointer to convert.
 *	len: Length to convert.
 * Return value: Returns a null-terminated string.
 */

char *cnvstr(char *s, int len) {
	char *p = malloc(len+1);
	memcpy(p, s, len);
	p[len] = '\0';
	return p;
}