Skip to content

Commit 7444fb7

Browse files
authored
Merge pull request #123 from saxbophone/develop
Add some missing assertions - v0.20.1
2 parents 53c0568 + 25bb0f1 commit 7444fb7

File tree

4 files changed

+16
-2
lines changed

4 files changed

+16
-2
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
# begin basic metadata
2424
cmake_minimum_required(VERSION 3.0)
2525

26-
project(libsaxbospiral VERSION 0.20.0 LANGUAGES C)
26+
project(libsaxbospiral VERSION 0.20.1 LANGUAGES C)
2727

2828
# set default C standard to use (C99)
2929
set(SAXBOSPIRAL_C_STANDARD "99")

saxbospiral/render.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,16 @@ extern "C"{
3939
* 2-item-long array of type co_ord_t, find and store the co-ords for the
4040
* corners of the square needed to contain the points.
4141
* NOTE: This should NEVER be called with a pointer to anything other than a
42-
* 2-item struct of type co_ord_t
42+
* 2-item array of type co_ord_t
4343
*
4444
* Asserts:
4545
* - That spiral.co_ord_cache.co_ords.items is not NULL
46+
* - That bounds is not NULL
4647
*/
4748
static void get_bounds(sxbp_spiral_t spiral, sxbp_co_ord_t* bounds) {
4849
// preconditional assertions
4950
assert(spiral.co_ord_cache.co_ords.items != NULL);
51+
assert(bounds != NULL);
5052
sxbp_tuple_item_t min_x = 0;
5153
sxbp_tuple_item_t min_y = 0;
5254
sxbp_tuple_item_t max_x = 0;

saxbospiral/render_backends/png_backend.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
* You should have received a copy of the GNU Affero General Public License
2121
* along with this program. If not, see <http://www.gnu.org/licenses/>.
2222
*/
23+
#include <assert.h>
2324
#include <stdlib.h>
2425
#include <string.h>
2526

@@ -83,10 +84,17 @@ static void cleanup_png_lib(
8384
* given a bitmap_t struct and a pointer to a blank buffer_t, write the bitmap
8485
* data as a PNG image to the buffer, using libpng.
8586
* returns a status struct containing error information, if any
87+
*
88+
* Asserts:
89+
* - That bitmap.pixels is not NULL
90+
* - That buffer->bytes is NULL
8691
*/
8792
sxbp_status_t sxbp_write_png_image(
8893
sxbp_bitmap_t bitmap, sxbp_buffer_t* buffer
8994
) {
95+
// preconditional assertsions
96+
assert(bitmap.pixels != NULL);
97+
assert(buffer->bytes == NULL);
9098
// result status
9199
sxbp_status_t result;
92100
// init buffer

saxbospiral/render_backends/png_backend.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ extern "C"{
3535
* given a bitmap_t struct and a pointer to a blank buffer_t, write the bitmap
3636
* data as a PNG image to the buffer, using libpng.
3737
* returns a status struct containing error information, if any
38+
*
39+
* Asserts:
40+
* - That bitmap.pixels is not NULL
41+
* - That buffer->bytes is NULL
3842
*/
3943
sxbp_status_t sxbp_write_png_image(sxbp_bitmap_t bitmap, sxbp_buffer_t* buffer);
4044

0 commit comments

Comments
 (0)