Skip to content
Extraits de code Groupes Projets
Vérifiée Valider e119a347 rédigé par Kubat's avatar Kubat
Parcourir les fichiers

Bufferfd update, less dirty bomb

parent bb107fa5
Aucune branche associée trouvée
Aucune étiquette associée trouvée
1 requête de fusion!77Kara downloader update
...@@ -42,7 +42,7 @@ ssize_t bufferfd_bytes(struct bufferfd *bf, size_t n, uint8_t *res); ...@@ -42,7 +42,7 @@ ssize_t bufferfd_bytes(struct bufferfd *bf, size_t n, uint8_t *res);
ssize_t bufferfd_byte(struct bufferfd *bf, uint8_t *res); ssize_t bufferfd_byte(struct bufferfd *bf, uint8_t *res);
/* Consume `n` bytes without returning them. */ /* Consume `n` bytes without returning them. */
ssize_t bufferfd_skip(struct bufferfd *bf, size_t n); ssize_t bufferfd_skip(struct bufferfd *bf, const size_t n);
/* Move the file cursor to the absolute position `pos` (0 is the beginning of /* Move the file cursor to the absolute position `pos` (0 is the beginning of
* the file). * the file).
......
...@@ -5,8 +5,8 @@ ...@@ -5,8 +5,8 @@
#include <lektor/bufferfd.h> #include <lektor/bufferfd.h>
static ssize_t static inline ssize_t
bufferfd_fill(struct bufferfd *bf) __fill(struct bufferfd *bf)
{ {
if (bf->len <= bf->pos) { if (bf->len <= bf->pos) {
ssize_t n = read(bf->fd, bf->buffer, BUFFER_MAX); ssize_t n = read(bf->fd, bf->buffer, BUFFER_MAX);
...@@ -24,8 +24,7 @@ bufferfd_fill(struct bufferfd *bf) ...@@ -24,8 +24,7 @@ bufferfd_fill(struct bufferfd *bf)
ssize_t ssize_t
bufferfd_bytes(struct bufferfd *bf, size_t n, uint8_t *res) bufferfd_bytes(struct bufferfd *bf, size_t n, uint8_t *res)
{ {
// TODO repeat until n is reached ssize_t r = __fill(bf); /* TODO repeat until n is reached */
ssize_t r = bufferfd_fill(bf);
if (r < (ssize_t) n) if (r < (ssize_t) n)
return -1; return -1;
...@@ -41,14 +40,19 @@ bufferfd_byte(struct bufferfd *bf, uint8_t *res) ...@@ -41,14 +40,19 @@ bufferfd_byte(struct bufferfd *bf, uint8_t *res)
return bufferfd_bytes(bf, 1, res); return bufferfd_bytes(bf, 1, res);
} }
ssize_t static inline ssize_t
bufferfd_skip(struct bufferfd *bf, size_t n) __skip(struct bufferfd *bf, const size_t n, const size_t b_size)
{ {
// TODO less dirty bomb uint8_t b[b_size];
uint8_t b[4096];
return bufferfd_bytes(bf, n, b); return bufferfd_bytes(bf, n, b);
} }
ssize_t
bufferfd_skip(struct bufferfd *bf, const size_t n)
{
return __skip(bf, n, n > BUFFER_MAX ? BUFFER_MAX : n);
}
ssize_t ssize_t
bufferfd_seek(struct bufferfd *bf, size_t pos) bufferfd_seek(struct bufferfd *bf, size_t pos)
{ {
......
...@@ -23,14 +23,14 @@ ...@@ -23,14 +23,14 @@
#define EBML_MKV_TAGS 0x1254c367 #define EBML_MKV_TAGS 0x1254c367
#define EBML_MKV_TAG 0x00007373 #define EBML_MKV_TAG 0x00007373
#define EBML_MKV_TAG_TARGETS 0x000063c0 #define EBML_MKV_TAG_TARGETS 0x000063c0
#define EBML_MKV_TAG_TTV 0x000068ca // TargetTypeValue #define EBML_MKV_TAG_TTV 0x000068ca /* TargetTypeValue */
#define EBML_MKV_TAG_SIMPLE 0x000067c8 // SimpleTag #define EBML_MKV_TAG_SIMPLE 0x000067c8 /* SimpleTag */
#define EBML_MKV_TAG_NAME 0x000045a3 #define EBML_MKV_TAG_NAME 0x000045a3
#define EBML_MKV_TAG_STRING 0x00004487 #define EBML_MKV_TAG_STRING 0x00004487
#define EBML_MKV_TAG_BINARY 0x00004485 #define EBML_MKV_TAG_BINARY 0x00004485
#define EBML_MKV_CRC32 0x0000000bf // CRC-32, they skip it in mpv (demux/ebml.c:463 aprox) #define EBML_MKV_CRC32 0x0000000bf /* CRC-32, they skip it in mpv (demux/ebml.c:463 aprox) */
#define EBML_MKV_VOID 0x0000000ec // VOID element #define EBML_MKV_VOID 0x0000000ec /* VOID element */
/* mkv_read_* functions take data from the bufferfd and parse the next "*" (one /* mkv_read_* functions take data from the bufferfd and parse the next "*" (one
* of the following): * of the following):
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter