File: DStrNew.c

package info (click to toggle)
ncftp 2%3A3.2.5-2
  • links: PTS
  • area: main
  • in suites: stretch
  • size: 3,376 kB
  • ctags: 3,358
  • sloc: ansic: 39,640; sh: 3,560; makefile: 897; cpp: 612; perl: 101
file content (23 lines) | stat: -rw-r--r-- 420 bytes parent folder | download | duplicates (11)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include "syshdrs.h"
#ifdef PRAGMA_HDRSTOP
#	pragma hdrstop
#endif

int
DStrNew(DStr *const dst, const size_t srcLen)
{
	size_t allocSize;
	char *cp;

	memset(dst, 0, sizeof(DStr));
	if (srcLen > 0x00FFFFFF)
		return (-1);
	allocSize = (srcLen + 16) & 0xFFFFFFF0;
	cp = calloc(allocSize, (size_t) 1);
	if (cp == NULL)
		return (-1);
	dst->allocSize = allocSize;
	dst->s = cp;
	dst->len = 0;
	return (0);
}	/* DStrNew */