AllocCountedString function

Note

The Network Access Protection platform is not available starting with Windows 10

The AllocCountedString function allocates memory for a null-terminated string and returns it in a CountedString structure.

Syntax

NAPAPI HRESULT WINAPI AllocCountedString(
  _Inout_       CountedString **countedString,
  _In_    const WCHAR         *string
);

Parameters

countedString [in, out]

A pointer to the address of a newly allocated CountedString structure.

string [in]

A pointer to the null-terminated string that is to be returned in countedString.

Return value

Return code Description
S_OK
The operation has completed successfully.
E_INVALIDARG
An invalid argument was passed.
E_OUTOFMEMORY
The system is out of virtual memory. This operation has failed.

Remarks

All the COM interfaces supported by the NAP system use standard COM memory management rules and the COM memory allocators (CoTaskMemAlloc and CoTaskMemFree):

  • In parameters are allocated and freed by the caller.
  • Out parameters are allocated by the callee and freed by the caller using CoTaskMem.
  • In/out parameters are allocated by the caller, freed and reallocated by the callee, and ultimately freed by the caller, using CoTaskMem.

All NAP functions for freeing memory also free all embedded pointers.

Requirements

Requirement Value
Minimum supported client
Windows Vista [desktop apps only]
Minimum supported server
Windows Server 2008 [desktop apps only]
Header
NapUtil.h
DLL
Qutil.dll

See also

FreeCountedString