10 typedef __int64 ssize_t;
27 lseek(
fp,0L,SEEK_CUR);
79 fp=open((
char*)(
filename), O_RDWR | O_CREAT | O_TRUNC |
82 fp=open((
char*)(
filename), O_RDWR | O_CREAT | O_TRUNC |
87 cerr <<
"Error trying to open file " <<
filename
88 <<
" in class fixed_smartlist " <<
endl;
93 lseek(
fp, 0L, SEEK_CUR);
102 #if defined(__MINGW64__) || (defined(_WIN64) && defined(_MSC_VER))
104 assert(n <= UINT_MAX);
110 if (nw <= -1 || (
size_t)nw != n)
126 lseek(
fp,0L,SEEK_SET);
128 unsigned int nbytes=0;
129 ssize_t ret =
::read(
fp,&nbytes,
sizeof(
unsigned int));
133 cerr <<
"Error -- record size in file seems to be larger than"
134 " the buffer it was created from " <<
endl
135 <<
" buffer size is " <<
bufsize <<
" record size is supposedly "
146 lseek(
fp, (off_t)
sizeof(off_t), SEEK_CUR);
148 ret = lseek(
fp, (off_t)
sizeof(off_t), SEEK_CUR);
165 lseek(
fp,0L,SEEK_SET);
185 cout <<
"Need to increase buffsize in list" <<
endl;
202 lseek(
fp, 0L, SEEK_END);
205 off_t ret = lseek(
fp, 0L, SEEK_END);
241 const unsigned int nbytes = (
unsigned int)_nbytes;
245 off_t
pos=lseek(
fp,0L,SEEK_CUR);
248 #if defined(OPT_LIB) && !defined(_MSC_VER)
249 ::write(
fp, &nbytes,
sizeof(
unsigned int));
251 ssize_t ret =
::write(
fp, &nbytes,
sizeof(
unsigned int));
260 if ((
size_t)nw < nbytes)
270 #if defined(OPT_LIB) && !defined(_MSC_VER)
291 unsigned int nbytes = (
unsigned int)_nbytes;
294 cerr <<
"n bytes > bufsize in "
295 "fixed_smartlist::write_buffer(void) this can't happen!" <<
endl;
299 off_t
pos=lseek(
fp,0L,SEEK_CUR);
302 ssize_t ret =
::write(
fp,&nbytes,
sizeof(
unsigned int));
310 if ((
size_t)nw < nbytes)
346 off_t ipos=lseek(
fp,0L,SEEK_CUR);
354 lseek(
fp,-((off_t)
sizeof(off_t)),SEEK_CUR);
355 ssize_t ret =
read(
fp,&pos,
sizeof(off_t));
358 lseek(
fp,pos,SEEK_SET);
362 unsigned int nbytes = 0;
363 ssize_t result =
::read(
fp,&nbytes,
sizeof(
unsigned int));
364 assert(result != -1);
367 cerr <<
"Error -- record size in file seems to be larger than"
368 " the buffer it was created from " <<
endl
369 <<
" buffer size is " <<
bufsize <<
" record size is supposedly "
378 if ((
size_t)nr != nbytes)
380 cerr <<
"Error reading -- should be " << nbytes <<
" got " << nr <<
endl;
394 lseek(
fp,pos,SEEK_SET);
396 off_t ret = lseek(
fp, pos, SEEK_SET);
405 lseek(
fp,(off_t)
sizeof(off_t),SEEK_CUR);
407 off_t ret = lseek(
fp, (off_t)
sizeof(off_t), SEEK_CUR);
421 if (list.bptr+nsize-1 > list.buffend)
423 cerr <<
" Trying to write outside list buffer" <<
endl;
426 memcpy(list.bptr,p,nsize);
437 if (list.bptr+nsize-1 > list.buffend)
439 cerr <<
" Trying to write outside list buffer" <<
endl;
442 memcpy(p,list.bptr,nsize);
452 cerr <<
" Sanity error in fixed_smartlist::operator -= (int)" <<
endl;
473 cerr <<
" Sanity error in fixed_smartlist::operator -= (int)" <<
endl;
500 if ((
unsigned int)nsize>
bufsize)
502 cout <<
"Need to increase buffsize in list" <<
endl;
543 off_t
pos=lseek(
fp,0L,SEEK_SET);
551 unsigned int nbytes=0;
552 nw =
::read(
fp,&nbytes,
sizeof(
unsigned int));
555 nw =
::read(
fp, buffer + offset, (
size_t)nbytes);
559 nw =
::read(
fp, &pos,
sizeof(off_t));
void read(const test_smartlist &, void *, int nsize)
void memcpy(test_smartlist &dest, void *source, const size_t nsize)
memcpy for test_smartlist
fixed_list_entry * recend
fixed_smartlist()
Default constructor.
void rewind(void)
Rewind buffer.
#define ADUNCONST(type, obj)
Creates a shallow copy of obj that is not CONST.
void allocate(const size_t bufsize, const adstring &filename)
int adptr_diff(void *x, void *y)
void restore_end(void)
Restore end.
void reset(void)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
#define AD_ALLOCATE(ptr, type, n, classname)
Description not yet available.
void initialize(void)
Description not yet available.
Description not yet available.
prnstream & endl(prnstream &)
void operator++(void)
Description not yet available.
fixed_list_entry * buffer
fixed_list_entry * true_buffer
void read_buffer(void)
Description not yet available.
static int get_passnumber(void)
void write_buffer(void)
Description not yet available.
fixed_list_entry * buffend
void check_buffer_size(const size_t)
Description not yet available.
size_t pos(const adstring &substr, const adstring &s)
void write_buffer_one_less(void)
Description not yet available.
Description not yet available.
Description not yet available.
fixed_list_entry * true_buffend
void save_end(void)
Description not yet available.