src/SDL_dataqueue.c
changeset 11582 cc0b1273a381
parent 10743 8ccdeceaae6d
child 11811 5d94cb6b24d3
equal deleted inserted replaced
11581:49393a9dffe4 11582:cc0b1273a381
   224 
   224 
   225     return 0;
   225     return 0;
   226 }
   226 }
   227 
   227 
   228 size_t
   228 size_t
       
   229 SDL_PeekIntoDataQueue(SDL_DataQueue *queue, void *_buf, const size_t _len)
       
   230 {
       
   231     size_t len = _len;
       
   232     Uint8 *buf = (Uint8 *) _buf;
       
   233     Uint8 *ptr = buf;
       
   234     SDL_DataQueuePacket *packet;
       
   235 
       
   236     if (!queue) {
       
   237         return 0;
       
   238     }
       
   239 
       
   240     for (packet = queue->head; len && packet; packet = packet->next) {
       
   241         const size_t avail = packet->datalen - packet->startpos;
       
   242         const size_t cpy = SDL_min(len, avail);
       
   243         SDL_assert(queue->queued_bytes >= avail);
       
   244 
       
   245         SDL_memcpy(ptr, packet->data + packet->startpos, cpy);
       
   246         ptr += cpy;
       
   247         len -= cpy;
       
   248     }
       
   249 
       
   250     return (size_t) (ptr - buf);
       
   251 }
       
   252 
       
   253 size_t
   229 SDL_ReadFromDataQueue(SDL_DataQueue *queue, void *_buf, const size_t _len)
   254 SDL_ReadFromDataQueue(SDL_DataQueue *queue, void *_buf, const size_t _len)
   230 {
   255 {
   231     size_t len = _len;
   256     size_t len = _len;
   232     Uint8 *buf = (Uint8 *) _buf;
   257     Uint8 *buf = (Uint8 *) _buf;
   233     Uint8 *ptr = buf;
   258     Uint8 *ptr = buf;