aboutsummaryrefslogtreecommitdiffstats
path: root/libparsepcf_get_metrics_count.c
diff options
context:
space:
mode:
authorMattias Andrée <m@maandree.se>2024-10-13 11:17:48 +0200
committerMattias Andrée <m@maandree.se>2024-10-13 11:17:48 +0200
commita81c96c0348af8caf6ae45e2d942a676792a2a31 (patch)
tree24cc725efa3eba381c98ebed7cb2cbf7e0e34f0c /libparsepcf_get_metrics_count.c
parentUpdate e-mail (diff)
downloadlibparsepcf-a81c96c0348af8caf6ae45e2d942a676792a2a31.tar.gz
libparsepcf-a81c96c0348af8caf6ae45e2d942a676792a2a31.tar.bz2
libparsepcf-a81c96c0348af8caf6ae45e2d942a676792a2a31.tar.xz
Documentation and minor improvements
Signed-off-by: Mattias Andrée <m@maandree.se>
Diffstat (limited to 'libparsepcf_get_metrics_count.c')
-rw-r--r--libparsepcf_get_metrics_count.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/libparsepcf_get_metrics_count.c b/libparsepcf_get_metrics_count.c
index fab5544..abaa542 100644
--- a/libparsepcf_get_metrics_count.c
+++ b/libparsepcf_get_metrics_count.c
@@ -3,8 +3,11 @@
int
-libparsepcf_get_metrics_count(const char *file, size_t size, const struct libparsepcf_table *table, size_t *countp)
+libparsepcf_get_metrics_count(const void *file, size_t size,
+ const struct libparsepcf_table *table,
+ size_t *count)
{
+ const char *text = file;
size_t pos;
int msb = table->format & LIBPARSEPCF_BYTE;
int compressed = table->format & LIBPARSEPCF_COMPRESSED_METRICS;
@@ -14,19 +17,19 @@ libparsepcf_get_metrics_count(const char *file, size_t size, const struct libpar
pos = table->offset;
- if (table->format != libparsepcf_parse_lsb_uint32__(&file[pos]))
+ if (table->format != libparsepcf_parse_lsb_uint32__(&text[pos]))
goto ebfont;
pos += 4;
if (compressed) {
- *countp = (size_t)PARSE_UINT16(&file[pos], msb);
+ *count = (size_t)PARSE_UINT16(&text[pos], msb);
pos += 2;
- if (*countp > (size - pos) / 5)
+ if (*count > (size - pos) / 5)
goto ebfont;
} else {
- *countp = (size_t)PARSE_UINT32(&file[pos], msb);
+ *count = (size_t)PARSE_UINT32(&text[pos], msb);
pos += 4;
- if (*countp > (size - pos) / 12)
+ if (*count > (size - pos) / 12)
goto ebfont;
}