summaryrefslogtreecommitdiff
path: root/src/str.c
blob: c69d8a8e1cbb6398ac59cc1a9e60308320287c49 (plain)
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
30
31
32
33
34
35
36
37
#ifdef HAVE_CONFIG_H
#  include <config.h>
#endif

#include <stdlib.h>
#include <string.h>

#include "err.h"
#include "mem.h"
#include "str.h"

char *
str_clone (char *str, size_t size)
{
	char *new;

	if (!str || !size)
		return NULL;	/* error */
	
	new = mem_new (char, size + 1);
	
	strncpy (new, str, size);
	new[size] = '\0';

	return new;
}

char *
str_delete (char *str)
{
	if (str)
		mem_free (str);

	str = 0;

	return 0;
}