Skip to content

Commit 69ce33d

Browse files
authored
Merge pull request #80 from saxbophone/josh/cleanup
Josh/cleanup
2 parents e1cefa3 + 900e50b commit 69ce33d

File tree

16 files changed

+63
-62
lines changed

16 files changed

+63
-62
lines changed

saxbospiral/initialise.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ direction_t change_direction(direction_t current, rotation_t turn) {
2424
* instructions which are then used to build the pattern.
2525
* returns a status_t struct with error information (if needed)
2626
*/
27-
status_t init_spiral(buffer_t buffer, spiral_t * spiral) {
27+
status_t init_spiral(buffer_t buffer, spiral_t* spiral) {
2828
// result status object
2929
status_t result;
3030
// number of lines is number of bits of the data, + 1 for the first UP line

saxbospiral/initialise.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ direction_t change_direction(direction_t current, rotation_t turn);
2121
* instructions which are then used to build the pattern.
2222
* returns a status_t struct with error information (if needed)
2323
*/
24-
status_t init_spiral(buffer_t buffer, spiral_t * spiral);
24+
status_t init_spiral(buffer_t buffer, spiral_t* spiral);
2525

2626
#ifdef __cplusplus
2727
} // extern "C"

saxbospiral/plot.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#include <stdint.h>
21
#include <stdlib.h>
32

43
#include "saxbospiral.h"
@@ -29,7 +28,7 @@ size_t sum_lines(spiral_t spiral, size_t start, size_t end) {
2928
* returns a status struct with error information (if any)
3029
*/
3130
status_t spiral_points(
32-
spiral_t spiral, co_ord_array_t * output, co_ord_t start_point,
31+
spiral_t spiral, co_ord_array_t* output, co_ord_t start_point,
3332
size_t start, size_t end
3433
) {
3534
// prepare result status
@@ -77,7 +76,7 @@ status_t spiral_points(
7776
* co_ord_cache member and are re-used if they are still valid
7877
* returns a status struct with error information (if any)
7978
*/
80-
status_t cache_spiral_points(spiral_t * spiral, size_t limit) {
79+
status_t cache_spiral_points(spiral_t* spiral, size_t limit) {
8180
// prepare result status
8281
status_t result = {{0, 0, 0}, 0};
8382
// the amount of space needed is the sum of all line lengths + 1 for end

saxbospiral/plot.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ size_t sum_lines(spiral_t spiral, size_t start, size_t end);
2424
* returns a status struct with error information (if any)
2525
*/
2626
status_t spiral_points(
27-
spiral_t spiral, co_ord_array_t * output, co_ord_t start_point,
27+
spiral_t spiral, co_ord_array_t* output, co_ord_t start_point,
2828
size_t start, size_t end
2929
);
3030

@@ -37,7 +37,7 @@ status_t spiral_points(
3737
* spiral's co_ord_cache member and are re-used if they are still valid
3838
* returns a status struct with error information (if any)
3939
*/
40-
status_t cache_spiral_points(spiral_t * spiral, size_t limit);
40+
status_t cache_spiral_points(spiral_t* spiral, size_t limit);
4141

4242
#ifdef __cplusplus
4343
} // extern "C"

saxbospiral/render.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ extern "C"{
2323
* NOTE: This should NEVER be called with a pointer to anything other than a
2424
* 2-item struct of type co_ord_t
2525
*/
26-
static void get_bounds(spiral_t spiral, co_ord_t * bounds) {
26+
static void get_bounds(spiral_t spiral, co_ord_t* bounds) {
2727
tuple_item_t min_x = 0;
2828
tuple_item_t min_y = 0;
2929
tuple_item_t max_x = 0;
@@ -54,7 +54,7 @@ static void get_bounds(spiral_t spiral, co_ord_t * bounds) {
5454
* representing a monochromatic image of the rendered spiral to the bitmap
5555
* returns a status struct with error information (if any)
5656
*/
57-
status_t render_spiral(spiral_t spiral, bitmap_t * image) {
57+
status_t render_spiral(spiral_t spiral, bitmap_t* image) {
5858
// create result status struct
5959
status_t result = {{0, 0, 0}, 0};
6060
// plot co-ords of spiral into it's cache

saxbospiral/render.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ typedef struct bitmap_t {
2727
* representing a monochromatic image of the rendered spiral to the bitmap
2828
* returns a status struct with error information (if any)
2929
*/
30-
status_t render_spiral(spiral_t spiral, bitmap_t * image);
30+
status_t render_spiral(spiral_t spiral, bitmap_t* image);
3131

3232
#ifdef __cplusplus
3333
} // extern "C"

saxbospiral/render_backends/png_backend.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ static void buffer_write_data(
1717
png_structp png_ptr, png_bytep data, png_size_t length
1818
) {
1919
// retrieve pointer to buffer
20-
buffer_t * p = (buffer_t *)png_get_io_ptr(png_ptr);
20+
buffer_t* p = (buffer_t*)png_get_io_ptr(png_ptr);
2121
size_t new_size = p->size + length;
2222
// if buffer bytes pointer is not NULL, then re-allocate
2323
if(p->bytes != NULL) {
@@ -55,7 +55,7 @@ void cleanup_png_lib(png_structp png_ptr, png_infop info_ptr, png_bytep row) {
5555
* data as a PNG image to the buffer, using libpng.
5656
* returns a status struct containing error information, if any
5757
*/
58-
status_t write_png_image(bitmap_t bitmap, buffer_t * buffer) {
58+
status_t write_png_image(bitmap_t bitmap, buffer_t* buffer) {
5959
// result status
6060
status_t result;
6161
// init buffer

saxbospiral/render_backends/png_backend.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ extern "C"{
1414
* data as a PNG image to the buffer, using libpng.
1515
* returns a status struct containing error information, if any
1616
*/
17-
status_t write_png_image(bitmap_t bitmap, buffer_t * buffer);
17+
status_t write_png_image(bitmap_t bitmap, buffer_t* buffer);
1818

1919
#ifdef __cplusplus
2020
} // extern "C"

saxbospiral/saxbospiral.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ version_hash_t version_hash(version_t version);
3535
// struct for storing the location of a DEBUG invocation
3636
typedef struct debug_t {
3737
size_t line;
38-
char * file;
39-
const char * function;
38+
char* file;
39+
const char* function;
4040
} debug_t;
4141

4242
/*
@@ -101,7 +101,7 @@ typedef tuple_t vector_t;
101101
typedef tuple_t co_ord_t;
102102

103103
typedef struct co_ord_array_t {
104-
co_ord_t * items;
104+
co_ord_t* items;
105105
size_t size;
106106
} co_ord_array_t;
107107

@@ -112,7 +112,7 @@ typedef struct co_ord_cache_t {
112112

113113
typedef struct spiral_t {
114114
uint64_t size; // count of lines
115-
line_t * lines; // dynamic array of lines
115+
line_t* lines; // dynamic array of lines
116116
co_ord_cache_t co_ord_cache; // co-ord cache for lines
117117
bool collides; // whether this spiral collides or not
118118
uint64_t collider; // the index of the line causing collision, if any
@@ -126,7 +126,7 @@ typedef struct spiral_t {
126126
} spiral_t;
127127

128128
typedef struct buffer_t {
129-
uint8_t * bytes;
129+
uint8_t* bytes;
130130
size_t size;
131131
} buffer_t;
132132

saxbospiral/serialise.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#warning "Please compile this code for a target with 64-bit words or greater."
44
#endif
55

6+
#include <stdint.h>
67
#include <stdio.h>
78
#include <stdlib.h>
89
#include <string.h>
@@ -64,7 +65,7 @@ static void dump_uint32_t(uint32_t value, buffer_t* buffer, size_t start_index)
6465
* whether the operation was successful or not and information about what went
6566
* wrong if it was not successful
6667
*/
67-
serialise_result_t load_spiral(buffer_t buffer, spiral_t * spiral) {
68+
serialise_result_t load_spiral(buffer_t buffer, spiral_t* spiral) {
6869
serialise_result_t result; // build struct for returning success / failure
6970
// first, if header is too small for header + 1 line, then return early
7071
if(buffer.size < FILE_HEADER_SIZE + LINE_T_PACK_SIZE) {
@@ -74,7 +75,7 @@ serialise_result_t load_spiral(buffer_t buffer, spiral_t * spiral) {
7475
return result;
7576
}
7677
// check for magic number and return early if not right
77-
if(strncmp((char *)buffer.bytes, "SAXBOSPIRAL", 11) != 0) {
78+
if(strncmp((char*)buffer.bytes, "SAXBOSPIRAL", 11) != 0) {
7879
result.status.location = DEBUG; // catch location of error
7980
result.status.diagnostic = OPERATION_FAIL; // flag failure
8081
result.diagnostic = DESERIALISE_BAD_MAGIC_NUMBER; // failure reason
@@ -153,7 +154,7 @@ serialise_result_t load_spiral(buffer_t buffer, spiral_t * spiral) {
153154
* whether the operation was successful or not and information about what went
154155
* wrong if it was not successful
155156
*/
156-
serialise_result_t dump_spiral(spiral_t spiral, buffer_t * buffer) {
157+
serialise_result_t dump_spiral(spiral_t spiral, buffer_t* buffer) {
157158
serialise_result_t result; // build struct for returning success / failure
158159
// populate buffer struct, base size on header + spiral size
159160
buffer->size = (FILE_HEADER_SIZE + (LINE_T_PACK_SIZE * spiral.size));
@@ -167,7 +168,7 @@ serialise_result_t dump_spiral(spiral_t spiral, buffer_t * buffer) {
167168
}
168169
// write first part of data header (magic number and version info)
169170
sprintf(
170-
(char *)buffer->bytes, "SAXBOSPIRAL\n%c%c%c\n",
171+
(char*)buffer->bytes, "SAXBOSPIRAL\n%c%c%c\n",
171172
VERSION.major, VERSION.minor, VERSION.patch
172173
);
173174
// write second part of data header (size, solved count and seconds fields)

0 commit comments

Comments
 (0)