diff options
author | Thomas Jarosch <tomj@simonv.com> | 2014-12-29 23:36:50 +0100 |
---|---|---|
committer | Thomas Jarosch <tomj@simonv.com> | 2014-12-29 23:49:12 +0100 |
commit | da5a36d6d298de44da687797f7547ab17b58d043 (patch) | |
tree | 61395e9c7e7b02ec44b1dcda8c4fa2c0d3a9aed9 | |
parent | 193c5df75d3b6d9e3442e42fa26fd8ccc4c5e3aa (diff) | |
download | rockbox-da5a36d6d298de44da687797f7547ab17b58d043.tar.gz rockbox-da5a36d6d298de44da687797f7547ab17b58d043.zip |
Document 'union buflib_data'
Change-Id: Ia98fa8e7887338d6c0b7a5795a0ae5c7a13014ba
-rw-r--r-- | firmware/buflib.c | 4 | ||||
-rw-r--r-- | firmware/include/buflib.h | 15 |
2 files changed, 11 insertions, 8 deletions
diff --git a/firmware/buflib.c b/firmware/buflib.c index 8d5fe1eef3..b6e5551efb 100644 --- a/firmware/buflib.c +++ b/firmware/buflib.c | |||
@@ -44,7 +44,7 @@ | |||
44 | * the buffer. The buffer is treated as an array of union buflib_data. Blocks | 44 | * the buffer. The buffer is treated as an array of union buflib_data. Blocks |
45 | * start with a length marker, which is included in their length. Free blocks | 45 | * start with a length marker, which is included in their length. Free blocks |
46 | * are marked by negative length. Allocated blocks have a positiv length marker, | 46 | * are marked by negative length. Allocated blocks have a positiv length marker, |
47 | * and additional metadata forllowing that: It follows a pointer | 47 | * and additional metadata following that: It follows a pointer |
48 | * (union buflib_data*) to the corresponding handle table entry. so that it can | 48 | * (union buflib_data*) to the corresponding handle table entry. so that it can |
49 | * be quickly found and updated during compaction. After that follows | 49 | * be quickly found and updated during compaction. After that follows |
50 | * the pointer to the struct buflib_callbacks associated with this allocation | 50 | * the pointer to the struct buflib_callbacks associated with this allocation |
@@ -62,7 +62,7 @@ | |||
62 | * |L|H|C|cccc|L2|crc|XXXXXX|-L|YYYYYYYYYYYYYYYY|L|H|C|cc|L2|crc|XXXXXXXXXXXXX|AAA| | 62 | * |L|H|C|cccc|L2|crc|XXXXXX|-L|YYYYYYYYYYYYYYYY|L|H|C|cc|L2|crc|XXXXXXXXXXXXX|AAA| |
63 | * | 63 | * |
64 | * L - length marker (negative if block unallocated) | 64 | * L - length marker (negative if block unallocated) |
65 | * H - handle table enry pointer | 65 | * H - handle table entry pointer |
66 | * C - pointer to struct buflib_callbacks | 66 | * C - pointer to struct buflib_callbacks |
67 | * c - variable sized string identifier | 67 | * c - variable sized string identifier |
68 | * L2 - second length marker for string identifier | 68 | * L2 - second length marker for string identifier |
diff --git a/firmware/include/buflib.h b/firmware/include/buflib.h index d1ff58720b..50722bb351 100644 --- a/firmware/include/buflib.h +++ b/firmware/include/buflib.h | |||
@@ -35,12 +35,15 @@ | |||
35 | 35 | ||
36 | union buflib_data | 36 | union buflib_data |
37 | { | 37 | { |
38 | intptr_t val; | 38 | intptr_t val; /* length of the block in n*sizeof(union buflib_data). |
39 | char name[1]; /* actually a variable sized string */ | 39 | Includes buflib metadata overhead. A negative value |
40 | struct buflib_callbacks* ops; | 40 | indicates block is unallocated */ |
41 | char* alloc; | 41 | char name[1]; /* name, actually a variable sized string */ |
42 | union buflib_data *handle; | 42 | struct buflib_callbacks* ops; /* callback functions for move and shrink. Can be NULL */ |
43 | uint32_t crc; | 43 | char* alloc; /* start of allocated memory area */ |
44 | union buflib_data *handle; /* pointer to entry in the handle table. | ||
45 | Used during compaction for fast lookup */ | ||
46 | uint32_t crc; /* checksum of this data to detect corruption */ | ||
44 | }; | 47 | }; |
45 | 48 | ||
46 | struct buflib_context | 49 | struct buflib_context |