this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Added GPU_SetErrorStackMax().

+41 -13
+3
include/SDL_gpu.h
··· 703 703 /*! Gets the string representation of an error code. */ 704 704 DECLSPEC const char* SDLCALL GPU_GetErrorString(GPU_ErrorEnum error); 705 705 706 + /*! Changes the maximum number of error objects that SDL_gpu will store. This deletes all currently stored errors. */ 707 + DECLSPEC void SDLCALL GPU_SetErrorStackMax(unsigned int max); 708 + 706 709 // End of Logging 707 710 /*! @} */ 708 711
+38 -13
src/SDL_gpu.c
··· 34 34 35 35 static GPU_DebugLevelEnum debug_level = GPU_DEBUG_LEVEL_0; 36 36 37 - #define GPU_MAX_NUM_ERRORS 20 37 + #define GPU_DEFAULT_MAX_NUM_ERRORS 20 38 38 #define GPU_ERROR_FUNCTION_STRING_MAX 128 39 39 #define GPU_ERROR_DETAILS_STRING_MAX 512 40 - static GPU_ErrorObject error_code_stack[GPU_MAX_NUM_ERRORS]; 41 - static int num_error_codes = 0; 42 - static int inited_error_code_stack = 0; 40 + static GPU_ErrorObject* error_code_stack = NULL; 41 + static unsigned int num_error_codes = 0; 42 + static unsigned int error_code_stack_size = GPU_DEFAULT_MAX_NUM_ERRORS; 43 43 44 44 /*! A mapping of windowID to a GPU_Target to facilitate GPU_GetWindowTarget(). */ 45 45 typedef struct GPU_WindowMapping ··· 191 191 192 192 static void init_error_stack(void) 193 193 { 194 - if(!inited_error_code_stack) 194 + if(error_code_stack == NULL) 195 195 { 196 - int i; 197 - inited_error_code_stack = 1; 198 - for(i = 0; i < GPU_MAX_NUM_ERRORS; i++) 196 + unsigned int i; 197 + error_code_stack = (GPU_ErrorObject*)malloc(sizeof(GPU_ErrorObject)*error_code_stack_size); 198 + 199 + for(i = 0; i < error_code_stack_size; i++) 199 200 { 200 201 error_code_stack[i].function = (char*)malloc(GPU_ERROR_FUNCTION_STRING_MAX+1); 201 202 error_code_stack[i].details = (char*)malloc(GPU_ERROR_DETAILS_STRING_MAX+1); 202 203 } 204 + num_error_codes = 0; 203 205 } 204 206 } 205 207 ··· 519 521 image->using_virtual_resolution = 0; 520 522 } 521 523 524 + // Deletes all existing errors 525 + void GPU_SetErrorStackMax(unsigned int max) 526 + { 527 + unsigned int i; 528 + // Free the error stack 529 + for(i = 0; i < error_code_stack_size; i++) 530 + { 531 + free(error_code_stack[i].function); 532 + error_code_stack[i].function = NULL; 533 + free(error_code_stack[i].details); 534 + error_code_stack[i].details = NULL; 535 + } 536 + free(error_code_stack); 537 + error_code_stack = NULL; 538 + num_error_codes = 0; 539 + 540 + // Reallocate with new size 541 + error_code_stack_size = max; 542 + init_error_stack(); 543 + } 544 + 522 545 void GPU_CloseCurrentRenderer(void) 523 546 { 524 547 if(current_renderer == NULL) ··· 530 553 531 554 void GPU_Quit(void) 532 555 { 533 - int i; 556 + unsigned int i; 534 557 if(num_error_codes > 0 && GPU_GetDebugLevel() >= GPU_DEBUG_LEVEL_1) 535 - GPU_LogError("GPU_Quit: %d uncleared errors.\n", num_error_codes); 558 + GPU_LogError("GPU_Quit: %d uncleared error%s.\n", num_error_codes, (num_error_codes > 1? "s" : "")); 536 559 537 560 // Free the error stack 538 - for(i = 0; i < GPU_MAX_NUM_ERRORS; i++) 561 + for(i = 0; i < error_code_stack_size; i++) 539 562 { 540 563 free(error_code_stack[i].function); 541 564 error_code_stack[i].function = NULL; 542 565 free(error_code_stack[i].details); 543 566 error_code_stack[i].details = NULL; 544 567 } 545 - inited_error_code_stack = 0; 568 + free(error_code_stack); 569 + error_code_stack = NULL; 570 + num_error_codes = 0; 546 571 547 572 if(current_renderer == NULL) 548 573 return; ··· 586 611 GPU_LogError("%s: %s\n", (function == NULL? "NULL" : function), GPU_GetErrorString(error)); 587 612 } 588 613 589 - if(num_error_codes < GPU_MAX_NUM_ERRORS) 614 + if(num_error_codes < error_code_stack_size) 590 615 { 591 616 if(function == NULL) 592 617 error_code_stack[num_error_codes].function[0] = '\0';