main() { int where; char *whine; void *f; char *text; int size; f = newchunk(stdin, ":"); while ( (text = getchunk(f, &size)) ) printf("[%.*s]\n", size, text); freechunk(f); }
/** * It defines the enqueue operation */ inline void push_back(const elem_type & elem) { T * current = data[tail].entry; int current_tail = data[tail].t++; if ((unsigned)current_tail == (chunk-1)) { if (tail == (datacap-1)) { datacap += DATA_CHUNK; data = (data_type *)realloc(data, datacap*sizeof(data_type)); } T * v = newchunk(); data[++tail] = data_type(0,0,v); current = v; current_tail=-1; } current[current_tail+1] = elem; ++nelements; }
/** * TODO */ squeue(size_t chunk=SQUEUE_CHUNK):data(0),datacap(DATA_CHUNK), nelements(0), head(0),tail(0),chunk(chunk) { data = (data_type *)malloc(datacap*sizeof(data_type)); data[0] = data_type(0, -1, newchunk()); }