Minor tweaks
Error handling in cx_init(). More warnings with -Wpedantic.
This commit is contained in:
parent
afc9aec314
commit
3da9e7df5a
3 changed files with 24 additions and 5 deletions
|
@ -1,5 +1,5 @@
|
||||||
# CMake entry point
|
# CMake entry point
|
||||||
cmake_minimum_required (VERSION 3.30.5)
|
cmake_minimum_required(VERSION 3.31.0)
|
||||||
project(CX C)
|
project(CX C)
|
||||||
cmake_policy(SET CMP0072 NEW)
|
cmake_policy(SET CMP0072 NEW)
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ set(ALL_LIBS
|
||||||
pthread
|
pthread
|
||||||
)
|
)
|
||||||
|
|
||||||
set(CMAKE_C_FLAGS "-O0 -ggdb -Wall")
|
set(CMAKE_C_FLAGS "-O0 -ggdb -Wall -std=gnu99 -Wpedantic")
|
||||||
|
|
||||||
add_definitions(
|
add_definitions(
|
||||||
-DTW_STATIC
|
-DTW_STATIC
|
||||||
|
|
24
src/cx.c
24
src/cx.c
|
@ -185,22 +185,42 @@ cx_init(CX_Context **cx_ctx) {
|
||||||
|
|
||||||
*cx_ctx = calloc(1, sizeof(CX_Context));
|
*cx_ctx = calloc(1, sizeof(CX_Context));
|
||||||
(*cx_ctx)->VertexArrayIDs = calloc(1, sizeof(GLuint));
|
(*cx_ctx)->VertexArrayIDs = calloc(1, sizeof(GLuint));
|
||||||
|
if (!(*cx_ctx)->VertexArrayIDs) {
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
(*cx_ctx)->VertexArray_count = 0;
|
(*cx_ctx)->VertexArray_count = 0;
|
||||||
(*cx_ctx)->VertexArray_size = 1;
|
(*cx_ctx)->VertexArray_size = 1;
|
||||||
(*cx_ctx)->programIDs = calloc(1, sizeof(GLuint));
|
(*cx_ctx)->programIDs = calloc(1, sizeof(GLuint));
|
||||||
|
if (!(*cx_ctx)->programIDs) {
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
(*cx_ctx)->ProgramID_count = 0;
|
(*cx_ctx)->ProgramID_count = 0;
|
||||||
(*cx_ctx)->ProgramID_size = 1;
|
(*cx_ctx)->ProgramID_size = 1;
|
||||||
(*cx_ctx)->threads = calloc(1, sizeof(CX_ThreadGroup));
|
(*cx_ctx)->threads = calloc(1, sizeof(CX_ThreadGroup));
|
||||||
|
if (!(*cx_ctx)->threads) {
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
|
||||||
if (cx_glinit(&(*cx_ctx)->window)) {
|
if (cx_glinit(&(*cx_ctx)->window)) {
|
||||||
return -1;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cx_nninit(&(*cx_ctx)->nn)) {
|
if (cx_nninit(&(*cx_ctx)->nn)) {
|
||||||
return -1;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
err:
|
||||||
|
if (*cx_ctx) {
|
||||||
|
free((*cx_ctx)->VertexArrayIDs);
|
||||||
|
free((*cx_ctx)->programIDs);
|
||||||
|
free((*cx_ctx)->threads);
|
||||||
|
}
|
||||||
|
|
||||||
|
free(*cx_ctx);
|
||||||
|
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
|
|
@ -7,7 +7,6 @@ main(void) {
|
||||||
|
|
||||||
int retval;
|
int retval;
|
||||||
|
|
||||||
|
|
||||||
if (cx_init(&cx_ctx)) {
|
if (cx_init(&cx_ctx)) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue