MCPcopy Create free account
hub / github.com/NetHack/NetHack / nhmd4_update

Function nhmd4_update

src/nhmd4.c:195–232  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

193}
194
195void
196nhmd4_update(
197 struct nhmd4_context *ctx,
198 const unsigned char *data,
199 size_t size)
200{
201 /* @UNSAFE */
202 quint32 saved_lo;
203 unsigned long used, free;
204
205 saved_lo = ctx->lo;
206 if ((ctx->lo = (saved_lo + size) & 0x1fffffff) < saved_lo)
207 ctx->hi++;
208 ctx->hi += (quint32)(size >> 29);
209
210 used = saved_lo & 0x3f;
211
212 if (used) {
213 free = 64 - used;
214
215 if (size < free) {
216 memcpy(&ctx->buffer[used], data, size);
217 return;
218 }
219
220 memcpy(&ctx->buffer[used], data, free);
221 data = (const unsigned char *) data + free;
222 size -= free;
223 nhmd4_body(ctx, ctx->buffer, 64);
224 }
225
226 if (size >= 64) {
227 data = nhmd4_body(ctx, data, size & ~0x3fUL);
228 size &= 0x3fUL;
229 }
230
231 memcpy(ctx->buffer, data, size);
232}
233
234void
235nhmd4_final(

Callers

nothing calls this directly

Calls 1

nhmd4_bodyFunction · 0.85

Tested by

no test coverage detected