MCPcopy Create free account
hub / github.com/OpenNI/OpenNI / xnOSStrPrefix

Function xnOSStrPrefix

Source/OpenNI/Win32/Win32Strings.cpp:101–135  ·  view source on GitHub ↗

--------------------------------------------------------------------------- Code ---------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

99// Code
100//---------------------------------------------------------------------------
101XN_C_API XnStatus xnOSStrPrefix(const XnChar* cpPrefixString, XnChar* cpDestString, const XnUInt32 nDestLength)
102{
103 // Local function variables
104 XnChar* cpTempBuffer = NULL;
105 XnSizeT nOutStringLength = 0;
106
107 // Validate the input/output pointers (to make sure none of them is NULL)
108 XN_VALIDATE_INPUT_PTR(cpPrefixString);
109 XN_VALIDATE_INPUT_PTR(cpDestString);
110
111 // Calculate the final string length
112 nOutStringLength = strlen(cpPrefixString) + strlen(cpDestString);
113
114 // Make sure the destination string can hold the required information
115 if (nOutStringLength >= nDestLength)
116 {
117 return (XN_STATUS_INTERNAL_BUFFER_TOO_SMALL);
118 }
119
120 // Allocate the temp buffer
121 XN_VALIDATE_CALLOC(cpTempBuffer, XnChar, nOutStringLength + sizeof(XnChar));
122
123 // Prefix the string
124 strncat (cpTempBuffer, cpPrefixString, nOutStringLength);
125 strncat (cpTempBuffer, cpDestString, nOutStringLength);
126
127 // Copy the temp buffer into the output
128 strncpy (cpDestString, cpTempBuffer, nOutStringLength);
129
130 // Free the temporary buffer
131 xnOSFree(cpTempBuffer);
132
133 // All is good...
134 return (XN_STATUS_OK);
135}
136
137XN_C_API XnStatus xnOSStrAppend(XnChar* cpDestString, const XnChar* cpSrcString, const XnUInt32 nDestLength)
138{

Callers 1

xnOSGetFileListFunction · 0.70

Calls 1

xnOSFreeFunction · 0.70

Tested by

no test coverage detected