MCPcopy Create free account
hub / github.com/davidgiven/fluxengine / adfPutCacheEntry

Function adfPutCacheEntry

dep/adflib/src/adf_cache.c:197–237  ·  view source on GitHub ↗

* adfPutCacheEntry * * remplaces one cache entry at the p offset, and returns its length */

Source from the content-addressed store, hash-verified

195 * remplaces one cache entry at the p offset, and returns its length
196 */
197int adfPutCacheEntry( struct bDirCacheBlock *dirc, int *p, struct CacheEntry *cEntry)
198{
199 int ptr, l;
200
201 ptr = *p;
202
203#ifdef LITT_ENDIAN
204 swLong(dirc->records+ptr, cEntry->header);
205 swLong(dirc->records+ptr+4, cEntry->size);
206 swLong(dirc->records+ptr+8, cEntry->protect);
207 swShort(dirc->records+ptr+16, cEntry->days);
208 swShort(dirc->records+ptr+18, cEntry->mins);
209 swShort(dirc->records+ptr+20, cEntry->ticks);
210#else
211 memcpy(dirc->records+ptr,&(cEntry->header),4);
212 memcpy(dirc->records+ptr+4,&(cEntry->size),4);
213 memcpy(dirc->records+ptr+8,&(cEntry->protect),4);
214 memcpy(dirc->records+ptr+16,&(cEntry->days),2);
215 memcpy(dirc->records+ptr+18,&(cEntry->mins),2);
216 memcpy(dirc->records+ptr+20,&(cEntry->ticks),2);
217#endif
218 dirc->records[ptr+22] =(signed char)cEntry->type;
219
220 dirc->records[ptr+23] = cEntry->nLen;
221 memcpy(dirc->records+ptr+24, cEntry->name, cEntry->nLen);
222
223 dirc->records[ptr+24+cEntry->nLen] = cEntry->cLen;
224 memcpy(dirc->records+ptr+24+cEntry->nLen+1, cEntry->comm, cEntry->cLen);
225
226/*puts("adfPutCacheEntry");*/
227
228 l = 25+cEntry->nLen+cEntry->cLen;
229 if ((l%2)==0)
230 return l;
231 else {
232 dirc->records[ptr+l] =(char)0;
233 return l+1;
234 }
235
236 /* ptr%2 must be == 0, if l%2==0, (ptr+l)%2==0 */
237}
238
239
240/*

Callers 2

adfAddInCacheFunction · 0.85
adfUpdateCacheFunction · 0.85

Calls 2

swLongFunction · 0.85
swShortFunction · 0.85

Tested by

no test coverage detected