File: DStrNew.c

package info (click to toggle)
ncftp 2%3A3.2.7-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,124 kB
  • sloc: ansic: 41,900; sh: 3,577; perl: 874; makefile: 854; cpp: 612
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 */