Minor tweaks

Error handling in cx_init().
More warnings with -Wpedantic.
This commit is contained in:
Marcel Plch 2024-11-10 17:40:30 +01:00
parent afc9aec314
commit 3da9e7df5a
Signed by: dormouse
GPG key ID: 2CA77596BC4BDFFE
3 changed files with 24 additions and 5 deletions

View file

@ -1,5 +1,5 @@
# CMake entry point
cmake_minimum_required (VERSION 3.30.5)
cmake_minimum_required(VERSION 3.31.0)
project(CX C)
cmake_policy(SET CMP0072 NEW)
@ -20,7 +20,7 @@ set(ALL_LIBS
pthread
)
set(CMAKE_C_FLAGS "-O0 -ggdb -Wall")
set(CMAKE_C_FLAGS "-O0 -ggdb -Wall -std=gnu99 -Wpedantic")
add_definitions(
-DTW_STATIC

View file

@ -185,22 +185,42 @@ cx_init(CX_Context **cx_ctx) {
*cx_ctx = calloc(1, sizeof(CX_Context));
(*cx_ctx)->VertexArrayIDs = calloc(1, sizeof(GLuint));
if (!(*cx_ctx)->VertexArrayIDs) {
goto err;
}
(*cx_ctx)->VertexArray_count = 0;
(*cx_ctx)->VertexArray_size = 1;
(*cx_ctx)->programIDs = calloc(1, sizeof(GLuint));
if (!(*cx_ctx)->programIDs) {
goto err;
}
(*cx_ctx)->ProgramID_count = 0;
(*cx_ctx)->ProgramID_size = 1;
(*cx_ctx)->threads = calloc(1, sizeof(CX_ThreadGroup));
if (!(*cx_ctx)->threads) {
goto err;
}
if (cx_glinit(&(*cx_ctx)->window)) {
return -1;
goto err;
}
if (cx_nninit(&(*cx_ctx)->nn)) {
return -1;
goto err;
}
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

View file

@ -7,7 +7,6 @@ main(void) {
int retval;
if (cx_init(&cx_ctx)) {
return -1;
}