Lines Matching defs:state
82 * Your state variables should live in the tsd_t struct below
207 * tsd_t is the state info struct that we pass around
264 * initialize your state variables here first
266 tsd_t *state = (tsd_t *)tsd;
268 strncpy(state->filename, optf, 255);
269 state->nbytes = opts;
270 state->open_read_close = opti;
280 tsd_t *state = (tsd_t *)tsd;
281 state->fd = -1;
282 state->buf = NULL;
284 if (state->clone) {
290 s = (char*)malloc(strlen(state->filename) + strlen(buf) + 1);
291 sprintf(s, "/tmp/%s%d", state->filename, (int)getpid());
292 if (cp(state->filename, s, S_IREAD|S_IWRITE) < 0) {
297 strcpy(state->filename, s);
300 CHK(state->fd = open(state->filename, 0));
301 CHK(state->buf = mmap(0, state->nbytes, PROT_READ,
302 MMAP_FLAGS, state->fd, 0));
315 tsd_t *state = (tsd_t *)tsd;
322 if (state->open_read_close) {
323 CHK(fd = open(state->filename, 0));
324 CHK(p = mmap(0, state->nbytes, PROT_READ, MMAP_FLAGS, fd, 0));
325 bread(p, state->nbytes);
327 munmap(p, state->nbytes);
329 bread(state->buf, state->nbytes);
341 tsd_t *state = (tsd_t *)tsd;
342 if (state->buf) munmap(state->buf, state->nbytes);
343 if (state->fd >= 0) close(state->fd);
344 if (state->clone) unlink(state->filename);