Home | History | Annotate | Download | only in libtests

Lines Matching refs:buffer

342    struct buffer_list *next;         /* next buffer in list */
343 png_byte buffer[1024]; /* the actual buffer */
346 struct buffer
348 struct buffer_list *last; /* last buffer in use */
349 size_t end_count; /* bytes in the last buffer */
350 struct buffer_list *current; /* current buffer being read */
352 struct buffer_list first; /* the very first buffer */
356 buffer_init(struct buffer *buffer)
357 /* Call this only once for a given buffer */
359 buffer->first.next = NULL;
360 buffer->last = NULL;
361 buffer->current = NULL;
366 buffer_start_write(struct buffer *buffer)
368 buffer->last = &buffer->first;
369 buffer->end_count = 0;
370 buffer->current = NULL;
375 buffer_start_read(struct buffer *buffer)
377 buffer->current = &buffer->first;
378 buffer->read_count = 0;
386 static struct buffer *
388 /* Used from libpng callbacks to get the current buffer */
390 return (struct buffer*)png_get_io_ptr(pp);
412 /* Load a buffer from a file; does the equivalent of buffer_start_write. On a
416 buffer_from_file(struct buffer *buffer, FILE *fp)
418 struct buffer_list *last = &buffer->first;
423 size_t r = fread(last->buffer+count, 1/*size*/,
424 (sizeof last->buffer)-count, fp);
430 if (count >= sizeof last->buffer)
432 assert(count == sizeof last->buffer);
451 buffer->last = last;
452 buffer->end_count = count;
538 struct buffer written_file; /* where the file gets written */
541 struct buffer original_file; /* Data read from the original file */
547 * structure, the (struct buffer) lists are maintained across calls - the
726 buffer_read(struct display *dp, struct buffer *bp, png_bytep data,
745 else if (read_count >= sizeof last->buffer)
747 /* Move to the next buffer: */
755 display_log(dp, INTERNAL_ERROR, "damaged buffer list");
761 avail = (sizeof last->buffer) - read_count;
765 memcpy(data, last->buffer + read_count, avail);
781 read_png(struct display *dp, struct buffer *bp, const char *operation,
1184 buffer_write(struct display *dp, struct buffer *buffer, png_bytep data,
1190 /* Write the data into the buffer, adding buffers as required */
1191 struct buffer_list *last = buffer->last;
1192 size_t end_count = buffer->end_count;
1198 if (end_count >= sizeof last->buffer)
1211 buffer->last = last; /* avoid the need to rewrite every time */
1215 avail = (sizeof last->buffer) - end_count;
1219 memcpy(last->buffer + end_count, data, avail);
1225 buffer->end_count = end_count;