Skip to content
This repository has been archived by the owner on Jun 6, 2024. It is now read-only.

Commit

Permalink
Change function prototypes to make dest come first (C stdlib convention)
Browse files Browse the repository at this point in the history
  • Loading branch information
golightlyb committed Dec 31, 2017
1 parent 8bff30c commit b5e05f5
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 12 deletions.
10 changes: 5 additions & 5 deletions bakefont3.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ size_t bf3_header_peek(bf3_filelike *filelike)
char buf[20];
uint16_t size;

size_t was_read = filelike->read(filelike, buf, 0, 20);
size_t was_read = filelike->read(buf, filelike, 0, 20);
if (was_read < 20) { return 0; }
if (0 != memcmp(buf, "BAKEFONTv3r1", 12)) { return 0; }

Expand All @@ -90,7 +90,7 @@ size_t bf3_header_peek(bf3_filelike *filelike)
}


bool bf3_header_load(bf3_info *info, bf3_filelike *filelike, char *hdr, size_t header_size)
bool bf3_header_load(bf3_info *info, char *hdr, bf3_filelike *filelike, size_t header_size)
{
// HEADER - 24 byte block
// b"BAKEFONTv3r0" # 0 | 12 | magic bytes, version 3 revision 0
Expand All @@ -102,7 +102,7 @@ bool bf3_header_load(bf3_info *info, bf3_filelike *filelike, char *hdr, size_t h

int w, h, d, num_fonts, num_modes, num_tables;

size_t was_read = filelike->read(filelike, hdr, 0, header_size);
size_t was_read = filelike->read(hdr, filelike, 0, header_size);
if (was_read < header_size) { goto fail; }

uint16_t v[3];
Expand Down Expand Up @@ -250,7 +250,7 @@ bool bf3_metrics_load(char *metrics, bf3_filelike *filelike, bf3_table *table)
{
if (table->metrics_size < 4) { goto fail; }

size_t was_read = filelike->read(filelike, metrics, table->metrics_offset, table->metrics_size);
size_t was_read = filelike->read(metrics, filelike, table->metrics_offset, table->metrics_size);
if (was_read < table->metrics_size) { goto fail; }

if (0 != memcmp(metrics, "GSET", 4)) { goto fail; }
Expand All @@ -270,7 +270,7 @@ bool bf3_kerning_load(char *kerning, bf3_filelike *filelike, bf3_table *table)
{
if (table->kerning_size < 4) { goto fail; }

size_t was_read = filelike->read(filelike, kerning, table->kerning_offset, table->kerning_size);
size_t was_read = filelike->read(kerning, filelike,table->kerning_offset, table->kerning_size);
if (was_read < table->kerning_size) { goto fail; }

if (0 != memcmp(kerning, "KERN", 4)) { goto fail; }
Expand Down
5 changes: 3 additions & 2 deletions bakefont3.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ struct bf3_filelike

// copy at most `numbytes` from ptr + offset into dest, and return
// the number of bytes copied.
size_t (*read)(bf3_filelike *filelike, char *dest, size_t offset, size_t numbytes);
size_t (*read)(char *dest, bf3_filelike *filelike, size_t offset, size_t numbytes);
};


Expand Down Expand Up @@ -239,7 +239,8 @@ size_t bf3_header_peek(bf3_filelike *filelike);

// Read the bf3 header into a buf, `hdr`, of at least size `header_size`.
// Use the header size returned previously by `bf3_header_peek`.
bool bf3_header_load(bf3_info *info, bf3_filelike *filelike, char *hdr, size_t header_size);
// Also stores information in `info`.
bool bf3_header_load(bf3_info *info, char *hdr, bf3_filelike *filelike, size_t header_size);

// Get a font by Font ID. The font ID is between 0 and (num_fonts - 1), where
// `num_fonts` is the `num_fonts` property of the `bf3_info` structure returned
Expand Down
4 changes: 2 additions & 2 deletions example-gl.c
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ GLuint create_vbo(size_t size)
// data and a pointer to a function that can read from that data at a given
// offset. Here's an implementation for reading from a FILE *.

size_t (read_FILE)(bf3_filelike *filelike, char *dest, size_t offset, size_t numbytes)
size_t (read_FILE)(char *dest, bf3_filelike *filelike, size_t offset, size_t numbytes)
{
FILE *src = (void *) filelike->ptr;

Expand Down Expand Up @@ -260,7 +260,7 @@ int main(int argc, char *argv[])

// parse the header and store some initial info
bf3_info info;
if (!bf3_header_load(&info, &data_reader, hdr, header_size))
if (!bf3_header_load(&info, hdr, &data_reader, header_size))
{ fprintf(stderr, "Error reading header\n"); return -1; }

if ((info.width < atlas.width) && (info.height < atlas.height))
Expand Down
4 changes: 2 additions & 2 deletions example.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
// data and a pointer to a function that can read from that data at a given
// offset. Here's an implementation for reading from a FILE *.

size_t (read_FILE)(bf3_filelike *filelike, char *dest, size_t offset, size_t numbytes)
size_t (read_FILE)(char *dest, bf3_filelike *filelike, size_t offset, size_t numbytes)
{
FILE *src = (void *) filelike->ptr;

Expand Down Expand Up @@ -107,7 +107,7 @@ int main(int argc, char *argv[])

// parse the header and store some initial info
bf3_info info;
if (!bf3_header_load(&info, &data_reader, hdr, header_size))
if (!bf3_header_load(&info, hdr, &data_reader, header_size))
{ fprintf(stderr, "Error reading header\n"); return -1; }
printf("header dimensions = %dx%dx%d\n",
info.width, info.height, info.depth);
Expand Down
3 changes: 2 additions & 1 deletion lib/png.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ bool read_png(image *img, FILE *fp)

// PNG has allocated rows for us.
// Although this is less efficient, for ease of implementation lets
// for now just copy this into our own structure.
// for now just copy this into our own structure. Doing this ourselves
// would need logic for interlaced PNGs.
png_bytep *row_pointers;
row_pointers = png_get_rows(png_ptr, info_ptr);

Expand Down

0 comments on commit b5e05f5

Please sign in to comment.