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

Function adfGetCacheEntry

dep/adflib/src/adf_cache.c:141–189  ·  view source on GitHub ↗

* adfGetCacheEntry * * Returns a cache entry, starting from the offset p (the index into records[]) * This offset is updated to the end of the returned entry. */

Source from the content-addressed store, hash-verified

139 * This offset is updated to the end of the returned entry.
140 */
141void adfGetCacheEntry(struct bDirCacheBlock *dirc, int *p, struct CacheEntry *cEntry)
142{
143 int ptr;
144
145 ptr = *p;
146
147/*printf("p=%d\n",ptr);*/
148
149#ifdef LITT_ENDIAN
150 cEntry->header = swapLong(dirc->records+ptr);
151 cEntry->size = swapLong(dirc->records+ptr+4);
152 cEntry->protect = swapLong(dirc->records+ptr+8);
153 cEntry->days = swapShort(dirc->records+ptr+16);
154 cEntry->mins = swapShort(dirc->records+ptr+18);
155 cEntry->ticks = swapShort(dirc->records+ptr+20);
156#else
157 cEntry->header = Long(dirc->records+ptr);
158 cEntry->size = Long(dirc->records+ptr+4);
159 cEntry->protect = Long(dirc->records+ptr+8);
160 cEntry->days = Short(dirc->records+ptr+16);
161 cEntry->mins = Short(dirc->records+ptr+18);
162 cEntry->ticks = Short(dirc->records+ptr+20);
163#endif
164 cEntry->type =(signed char) dirc->records[ptr+22];
165
166 cEntry->nLen = dirc->records[ptr+23];
167/* cEntry->name = (char*)malloc(sizeof(char)*(cEntry->nLen+1));
168 if (!cEntry->name)
169 return;
170*/ memcpy(cEntry->name, dirc->records+ptr+24, cEntry->nLen);
171 cEntry->name[(int)(cEntry->nLen)]='\0';
172
173 cEntry->cLen = dirc->records[ptr+24+cEntry->nLen];
174 if (cEntry->cLen>0) {
175/* cEntry->comm =(char*)malloc(sizeof(char)*(cEntry->cLen+1));
176 if (!cEntry->comm) {
177 free( cEntry->name ); cEntry->name=NULL;
178 return;
179 }
180*/ memcpy(cEntry->comm,dirc->records+ptr+24+cEntry->nLen+1,cEntry->cLen);
181 }
182 cEntry->comm[(int)(cEntry->cLen)]='\0';
183/*printf("cEntry->nLen %d cEntry->cLen %d %s\n",cEntry->nLen,cEntry->cLen,cEntry->name);*/
184 *p = ptr+24+cEntry->nLen+1+cEntry->cLen;
185
186 /* the starting offset of each record must be even (68000 constraint) */
187 if ((*p%2)!=0)
188 *p=(*p)+1;
189}
190
191
192/*

Callers 4

adfGetDirEntCacheFunction · 0.85
adfDelFromCacheFunction · 0.85
adfAddInCacheFunction · 0.85
adfUpdateCacheFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected