MCPcopy Create free account
hub / github.com/DentonW/DevIL / iClipString

Function iClipString

DevIL/src-IL/src/il_states.cpp:152–171  ·  view source on GitHub ↗

Clips a string to a certain length and returns a new string.

Source from the content-addressed store, hash-verified

150
151// Clips a string to a certain length and returns a new string.
152char *iClipString(char *String, ILuint MaxLen)
153{
154 char *Clipped;
155 ILuint Length;
156
157 if (String == NULL)
158 return NULL;
159
160 Length = ilCharStrLen(String); //ilStrLen(String);
161
162 Clipped = (char*)ialloc((MaxLen + 1) * sizeof(char) /*sizeof(ILchar)*/); // Terminating NULL makes it +1.
163 if (Clipped == NULL) {
164 return NULL;
165 }
166
167 memcpy(Clipped, String, MaxLen * sizeof(char) /*sizeof(ILchar)*/);
168 Clipped[Length] = 0;
169
170 return Clipped;
171}
172
173
174// Returns format-specific strings, truncated to MaxLen (not counting the terminating NULL).

Callers 1

iGetStringFunction · 0.85

Calls 1

ilCharStrLenFunction · 0.85

Tested by

no test coverage detected