Remove trailing spaces

This commit is contained in:
Ray 2022-08-02 00:36:31 +02:00
parent fe9e82b2e6
commit fd191a32ea
10 changed files with 74 additions and 74 deletions

View file

@ -3,14 +3,14 @@
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>raylib web game</title> <title>raylib web game</title>
<meta name="title" content="raylib web game"> <meta name="title" content="raylib web game">
<meta name="description" content="New raylib web videogame, developed using raylib videogames library"> <meta name="description" content="New raylib web videogame, developed using raylib videogames library">
<meta name="keywords" content="raylib, games, html5, programming, C, C++, library, learn, videogames"> <meta name="keywords" content="raylib, games, html5, programming, C, C++, library, learn, videogames">
<meta name="viewport" content="width=device-width"> <meta name="viewport" content="width=device-width">
<!-- Open Graph metatags for sharing --> <!-- Open Graph metatags for sharing -->
<meta property="og:title" content="raylib web game"> <meta property="og:title" content="raylib web game">
<meta property="og:image:type" content="image/png"> <meta property="og:image:type" content="image/png">
@ -26,10 +26,10 @@
<meta name="twitter:image" content="https://www.raylib.com/common/raylib_logo.png"> <meta name="twitter:image" content="https://www.raylib.com/common/raylib_logo.png">
<meta name="twitter:url" content="https://www.raylib.com/games.html"> <meta name="twitter:url" content="https://www.raylib.com/games.html">
<meta name="twitter:description" content="New raylib web game, developed using raylib videogames library"> <meta name="twitter:description" content="New raylib web game, developed using raylib videogames library">
<!-- Favicon --> <!-- Favicon -->
<link rel="shortcut icon" href="https://www.raylib.com/favicon.ico"> <link rel="shortcut icon" href="https://www.raylib.com/favicon.ico">
<style> <style>
body { margin: 0px; } body { margin: 0px; }
canvas.emscripten { border: 0px none; background-color: black; } canvas.emscripten { border: 0px none; background-color: black; }
@ -70,7 +70,7 @@
element.scrollTop = element.scrollHeight; // focus on bottom element.scrollTop = element.scrollHeight; // focus on bottom
} }
}; };
})(), })(),
canvas: (function() { canvas: (function() {
var canvas = document.getElementById('canvas'); var canvas = document.getElementById('canvas');
return canvas; return canvas;

View file

@ -1152,7 +1152,7 @@ void WaveFormat(Wave *wave, int sampleRate, int sampleSize, int channels)
ma_uint32 frameCountIn = wave->frameCount; ma_uint32 frameCountIn = wave->frameCount;
ma_uint32 frameCount = (ma_uint32)ma_convert_frames(NULL, 0, formatOut, channels, sampleRate, NULL, frameCountIn, formatIn, wave->channels, wave->sampleRate); ma_uint32 frameCount = (ma_uint32)ma_convert_frames(NULL, 0, formatOut, channels, sampleRate, NULL, frameCountIn, formatIn, wave->channels, wave->sampleRate);
if (frameCount == 0) if (frameCount == 0)
{ {
TRACELOG(LOG_WARNING, "WAVE: Failed to get frame count for format conversion"); TRACELOG(LOG_WARNING, "WAVE: Failed to get frame count for format conversion");
@ -1727,7 +1727,7 @@ void UpdateMusicStream(Music music)
// On first call of this function we lazily pre-allocated a temp buffer to read audio files/memory data in // On first call of this function we lazily pre-allocated a temp buffer to read audio files/memory data in
int frameSize = music.stream.channels*music.stream.sampleSize/8; int frameSize = music.stream.channels*music.stream.sampleSize/8;
unsigned int pcmSize = subBufferSizeInFrames*frameSize; unsigned int pcmSize = subBufferSizeInFrames*frameSize;
if (AUDIO.System.pcmBufferSize < pcmSize) if (AUDIO.System.pcmBufferSize < pcmSize)
{ {
RL_FREE(AUDIO.System.pcmBuffer); RL_FREE(AUDIO.System.pcmBuffer);
AUDIO.System.pcmBuffer = RL_CALLOC(1, pcmSize); AUDIO.System.pcmBuffer = RL_CALLOC(1, pcmSize);

View file

@ -760,7 +760,7 @@ RMAPI Vector3 Vector3RotateByAxisAngle(Vector3 v, Vector3 axis, float angle)
// Ref.: https://en.wikipedia.org/w/index.php?title=Euler%E2%80%93Rodrigues_formula // Ref.: https://en.wikipedia.org/w/index.php?title=Euler%E2%80%93Rodrigues_formula
Vector3 result = v; Vector3 result = v;
// Vector3Normalize(axis); // Vector3Normalize(axis);
float length = sqrtf(axis.x * axis.x + axis.y * axis.y + axis.z * axis.z); float length = sqrtf(axis.x * axis.x + axis.y * axis.y + axis.z * axis.z);
if (length == 0.0f) length = 1.0f; if (length == 0.0f) length = 1.0f;
@ -2099,7 +2099,7 @@ RMAPI int QuaternionEquals(Quaternion p, Quaternion q)
int result = (((fabsf(p.x - q.x)) <= (EPSILON*fmaxf(1.0f, fmaxf(fabsf(p.x), fabsf(q.x))))) && int result = (((fabsf(p.x - q.x)) <= (EPSILON*fmaxf(1.0f, fmaxf(fabsf(p.x), fabsf(q.x))))) &&
((fabsf(p.y - q.y)) <= (EPSILON*fmaxf(1.0f, fmaxf(fabsf(p.y), fabsf(q.y))))) && ((fabsf(p.y - q.y)) <= (EPSILON*fmaxf(1.0f, fmaxf(fabsf(p.y), fabsf(q.y))))) &&
((fabsf(p.z - q.z)) <= (EPSILON*fmaxf(1.0f, fmaxf(fabsf(p.z), fabsf(q.z))))) && ((fabsf(p.z - q.z)) <= (EPSILON*fmaxf(1.0f, fmaxf(fabsf(p.z), fabsf(q.z))))) &&
((fabsf(p.w - q.w)) <= (EPSILON*fmaxf(1.0f, fmaxf(fabsf(p.w), fabsf(q.w)))))) || ((fabsf(p.w - q.w)) <= (EPSILON*fmaxf(1.0f, fmaxf(fabsf(p.w), fabsf(q.w)))))) ||
(((fabsf(p.x + q.x)) <= (EPSILON*fmaxf(1.0f, fmaxf(fabsf(p.x), fabsf(q.x))))) && (((fabsf(p.x + q.x)) <= (EPSILON*fmaxf(1.0f, fmaxf(fabsf(p.x), fabsf(q.x))))) &&
((fabsf(p.y + q.y)) <= (EPSILON*fmaxf(1.0f, fmaxf(fabsf(p.y), fabsf(q.y))))) && ((fabsf(p.y + q.y)) <= (EPSILON*fmaxf(1.0f, fmaxf(fabsf(p.y), fabsf(q.y))))) &&
((fabsf(p.z + q.z)) <= (EPSILON*fmaxf(1.0f, fmaxf(fabsf(p.z), fabsf(q.z))))) && ((fabsf(p.z + q.z)) <= (EPSILON*fmaxf(1.0f, fmaxf(fabsf(p.z), fabsf(q.z))))) &&

View file

@ -482,7 +482,7 @@ void UpdateCamera(Camera *camera)
// Camera position update // Camera position update
// NOTE: On CAMERA_FIRST_PERSON player Y-movement is limited to player 'eyes position' // NOTE: On CAMERA_FIRST_PERSON player Y-movement is limited to player 'eyes position'
camera->position.y = CAMERA.playerEyesPosition; camera->position.y = CAMERA.playerEyesPosition;
// Camera swinging (y-movement), only when walking (some key pressed) // Camera swinging (y-movement), only when walking (some key pressed)
for (int i = 0; i < 6; i++) if (direction[i]) { swingCounter += GetFrameTime(); break; } for (int i = 0; i < 6; i++) if (direction[i]) { swingCounter += GetFrameTime(); break; }
camera->position.y -= sinf(2*PI*CAMERA_FIRST_PERSON_STEP_FREQUENCY*swingCounter)*CAMERA_FIRST_PERSON_SWINGING_DELTA; camera->position.y -= sinf(2*PI*CAMERA_FIRST_PERSON_STEP_FREQUENCY*swingCounter)*CAMERA_FIRST_PERSON_SWINGING_DELTA;

View file

@ -1411,7 +1411,7 @@ void SetWindowState(unsigned int flags)
{ {
TRACELOG(LOG_WARNING, "WINDOW: High DPI can only by configured before window initialization"); TRACELOG(LOG_WARNING, "WINDOW: High DPI can only by configured before window initialization");
} }
// State change: FLAG_WINDOW_MOUSE_PASSTHROUGH // State change: FLAG_WINDOW_MOUSE_PASSTHROUGH
if (((CORE.Window.flags & FLAG_WINDOW_MOUSE_PASSTHROUGH) != (flags & FLAG_WINDOW_MOUSE_PASSTHROUGH)) && ((flags & FLAG_WINDOW_MOUSE_PASSTHROUGH) > 0)) if (((CORE.Window.flags & FLAG_WINDOW_MOUSE_PASSTHROUGH) != (flags & FLAG_WINDOW_MOUSE_PASSTHROUGH)) && ((flags & FLAG_WINDOW_MOUSE_PASSTHROUGH) > 0))
{ {
@ -1519,7 +1519,7 @@ void ClearWindowState(unsigned int flags)
{ {
TRACELOG(LOG_WARNING, "WINDOW: High DPI can only by configured before window initialization"); TRACELOG(LOG_WARNING, "WINDOW: High DPI can only by configured before window initialization");
} }
// State change: FLAG_WINDOW_MOUSE_PASSTHROUGH // State change: FLAG_WINDOW_MOUSE_PASSTHROUGH
if (((CORE.Window.flags & FLAG_WINDOW_MOUSE_PASSTHROUGH) > 0) && ((flags & FLAG_WINDOW_MOUSE_PASSTHROUGH) > 0)) if (((CORE.Window.flags & FLAG_WINDOW_MOUSE_PASSTHROUGH) > 0) && ((flags & FLAG_WINDOW_MOUSE_PASSTHROUGH) > 0))
{ {
@ -1759,7 +1759,7 @@ int GetMonitorWidth(int monitor)
if ((monitor >= 0) && (monitor < monitorCount)) if ((monitor >= 0) && (monitor < monitorCount))
{ {
const GLFWvidmode *mode = glfwGetVideoMode(monitors[monitor]); const GLFWvidmode *mode = glfwGetVideoMode(monitors[monitor]);
if (mode) return mode->width; if (mode) return mode->width;
else TRACELOG(LOG_WARNING, "GLFW: Failed to find video mode for selected monitor"); else TRACELOG(LOG_WARNING, "GLFW: Failed to find video mode for selected monitor");
} }
@ -1778,7 +1778,7 @@ int GetMonitorHeight(int monitor)
if ((monitor >= 0) && (monitor < monitorCount)) if ((monitor >= 0) && (monitor < monitorCount))
{ {
const GLFWvidmode *mode = glfwGetVideoMode(monitors[monitor]); const GLFWvidmode *mode = glfwGetVideoMode(monitors[monitor]);
if (mode) return mode->height; if (mode) return mode->height;
else TRACELOG(LOG_WARNING, "GLFW: Failed to find video mode for selected monitor"); else TRACELOG(LOG_WARNING, "GLFW: Failed to find video mode for selected monitor");
} }
@ -2832,7 +2832,7 @@ bool FileExists(const char *fileName)
bool IsFileExtension(const char *fileName, const char *ext) bool IsFileExtension(const char *fileName, const char *ext)
{ {
#define MAX_FILE_EXTENSION_SIZE 16 #define MAX_FILE_EXTENSION_SIZE 16
bool result = false; bool result = false;
const char *fileExt = GetFileExtension(fileName); const char *fileExt = GetFileExtension(fileName);
@ -3113,14 +3113,14 @@ FilePathList LoadDirectoryFiles(const char *dirPath)
{ {
FilePathList files = { 0 }; FilePathList files = { 0 };
unsigned int fileCounter = 0; unsigned int fileCounter = 0;
struct dirent *entity; struct dirent *entity;
DIR *dir = opendir(dirPath); DIR *dir = opendir(dirPath);
if (dir != NULL) // It's a directory if (dir != NULL) // It's a directory
{ {
// SCAN 1: Count files // SCAN 1: Count files
while ((entity = readdir(dir)) != NULL) while ((entity = readdir(dir)) != NULL)
{ {
// NOTE: We skip '.' (current dir) and '..' (parent dir) filepaths // NOTE: We skip '.' (current dir) and '..' (parent dir) filepaths
if ((strcmp(entity->d_name, ".") != 0) && (strcmp(entity->d_name, "..") != 0)) fileCounter++; if ((strcmp(entity->d_name, ".") != 0) && (strcmp(entity->d_name, "..") != 0)) fileCounter++;
@ -3132,16 +3132,16 @@ FilePathList LoadDirectoryFiles(const char *dirPath)
for (unsigned int i = 0; i < files.capacity; i++) files.paths[i] = (char *)RL_MALLOC(MAX_FILEPATH_LENGTH*sizeof(char)); for (unsigned int i = 0; i < files.capacity; i++) files.paths[i] = (char *)RL_MALLOC(MAX_FILEPATH_LENGTH*sizeof(char));
closedir(dir); closedir(dir);
// SCAN 2: Read filepaths // SCAN 2: Read filepaths
// NOTE: Directory paths are also registered // NOTE: Directory paths are also registered
ScanDirectoryFiles(dirPath, &files, NULL); ScanDirectoryFiles(dirPath, &files, NULL);
// Security check: read files.count should match fileCounter // Security check: read files.count should match fileCounter
if (files.count != files.capacity) TRACELOG(LOG_WARNING, "FILEIO: Read files count do not match capacity allocated"); if (files.count != files.capacity) TRACELOG(LOG_WARNING, "FILEIO: Read files count do not match capacity allocated");
} }
else TRACELOG(LOG_WARNING, "FILEIO: Failed to open requested directory"); // Maybe it's a file... else TRACELOG(LOG_WARNING, "FILEIO: Failed to open requested directory"); // Maybe it's a file...
return files; return files;
} }
@ -3214,13 +3214,13 @@ FilePathList LoadDroppedFiles(void)
void UnloadDroppedFiles(FilePathList files) void UnloadDroppedFiles(FilePathList files)
{ {
// WARNING: files pointers are the same as internal ones // WARNING: files pointers are the same as internal ones
if (files.count > 0) if (files.count > 0)
{ {
for (unsigned int i = 0; i < files.count; i++) RL_FREE(files.paths[i]); for (unsigned int i = 0; i < files.count; i++) RL_FREE(files.paths[i]);
RL_FREE(files.paths); RL_FREE(files.paths);
CORE.Window.dropFileCount = 0; CORE.Window.dropFileCount = 0;
CORE.Window.dropFilepaths = NULL; CORE.Window.dropFilepaths = NULL;
} }
@ -3759,7 +3759,7 @@ void SetMouseScale(float scaleX, float scaleY)
float GetMouseWheelMove(void) float GetMouseWheelMove(void)
{ {
float result = 0.0f; float result = 0.0f;
#if !defined(PLATFORM_ANDROID) #if !defined(PLATFORM_ANDROID)
if (fabsf(CORE.Input.Mouse.currentWheelMove.x) > fabsf(CORE.Input.Mouse.currentWheelMove.y)) result = (float)CORE.Input.Mouse.currentWheelMove.x; if (fabsf(CORE.Input.Mouse.currentWheelMove.x) > fabsf(CORE.Input.Mouse.currentWheelMove.y)) result = (float)CORE.Input.Mouse.currentWheelMove.x;
else result = (float)CORE.Input.Mouse.currentWheelMove.y; else result = (float)CORE.Input.Mouse.currentWheelMove.y;
@ -3987,7 +3987,7 @@ static bool InitGraphicsDevice(int width, int height)
#endif #endif
} }
else glfwWindowHint(GLFW_SCALE_TO_MONITOR, GLFW_FALSE); else glfwWindowHint(GLFW_SCALE_TO_MONITOR, GLFW_FALSE);
// Mouse passthrough // Mouse passthrough
if ((CORE.Window.flags & FLAG_WINDOW_MOUSE_PASSTHROUGH) > 0) glfwWindowHint(GLFW_MOUSE_PASSTHROUGH, GLFW_TRUE); if ((CORE.Window.flags & FLAG_WINDOW_MOUSE_PASSTHROUGH) > 0) glfwWindowHint(GLFW_MOUSE_PASSTHROUGH, GLFW_TRUE);
else glfwWindowHint(GLFW_MOUSE_PASSTHROUGH, GLFW_FALSE); else glfwWindowHint(GLFW_MOUSE_PASSTHROUGH, GLFW_FALSE);
@ -5118,13 +5118,13 @@ void PollInputEvents(void)
} }
// Scan all files and directories in a base path // Scan all files and directories in a base path
// WARNING: files.paths[] must be previously allocated and // WARNING: files.paths[] must be previously allocated and
// contain enough space to store all required paths // contain enough space to store all required paths
static void ScanDirectoryFiles(const char *basePath, FilePathList *files, const char *filter) static void ScanDirectoryFiles(const char *basePath, FilePathList *files, const char *filter)
{ {
static char path[MAX_FILEPATH_LENGTH] = { 0 }; static char path[MAX_FILEPATH_LENGTH] = { 0 };
memset(path, 0, MAX_FILEPATH_LENGTH); memset(path, 0, MAX_FILEPATH_LENGTH);
struct dirent *dp = NULL; struct dirent *dp = NULL;
DIR *dir = opendir(basePath); DIR *dir = opendir(basePath);
@ -5136,7 +5136,7 @@ static void ScanDirectoryFiles(const char *basePath, FilePathList *files, const
(strcmp(dp->d_name, "..") != 0)) (strcmp(dp->d_name, "..") != 0))
{ {
sprintf(path, "%s/%s", basePath, dp->d_name); sprintf(path, "%s/%s", basePath, dp->d_name);
if (filter != NULL) if (filter != NULL)
{ {
if (IsFileExtension(path, filter)) if (IsFileExtension(path, filter))
@ -5163,7 +5163,7 @@ static void ScanDirectoryFilesRecursively(const char *basePath, FilePathList *fi
{ {
static char path[MAX_FILEPATH_LENGTH] = { 0 }; static char path[MAX_FILEPATH_LENGTH] = { 0 };
memset(path, 0, MAX_FILEPATH_LENGTH); memset(path, 0, MAX_FILEPATH_LENGTH);
struct dirent *dp = NULL; struct dirent *dp = NULL;
DIR *dir = opendir(basePath); DIR *dir = opendir(basePath);
@ -5460,11 +5460,11 @@ static void WindowDropCallback(GLFWwindow *window, int count, const char **paths
for (unsigned int i = 0; i < CORE.Window.dropFileCount; i++) RL_FREE(CORE.Window.dropFilepaths[i]); for (unsigned int i = 0; i < CORE.Window.dropFileCount; i++) RL_FREE(CORE.Window.dropFilepaths[i]);
RL_FREE(CORE.Window.dropFilepaths); RL_FREE(CORE.Window.dropFilepaths);
CORE.Window.dropFileCount = 0; CORE.Window.dropFileCount = 0;
CORE.Window.dropFilepaths = NULL; CORE.Window.dropFilepaths = NULL;
} }
// WARNING: Paths are freed by GLFW when the callback returns, we must keep an internal copy // WARNING: Paths are freed by GLFW when the callback returns, we must keep an internal copy
CORE.Window.dropFileCount = count; CORE.Window.dropFileCount = count;
CORE.Window.dropFilepaths = (char **)RL_CALLOC(CORE.Window.dropFileCount, sizeof(char *)); CORE.Window.dropFilepaths = (char **)RL_CALLOC(CORE.Window.dropFileCount, sizeof(char *));

View file

@ -1516,7 +1516,7 @@ void rlDisableTextureCubemap(void)
void rlTextureParameters(unsigned int id, int param, int value) void rlTextureParameters(unsigned int id, int param, int value)
{ {
glBindTexture(GL_TEXTURE_2D, id); glBindTexture(GL_TEXTURE_2D, id);
#if !defined(GRAPHICS_API_OPENGL_11) #if !defined(GRAPHICS_API_OPENGL_11)
// Reset anisotropy filter, in case it was set // Reset anisotropy filter, in case it was set
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 1.0f); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 1.0f);

View file

@ -214,21 +214,21 @@ static MemNode *__SplitMemNode(MemNode *const node, const size_t bytes)
MemNode *const r = ( MemNode* )(n + (node->size - bytes)); MemNode *const r = ( MemNode* )(n + (node->size - bytes));
node->size -= bytes; node->size -= bytes;
r->size = bytes; r->size = bytes;
return r; return r;
} }
static void __InsertMemNodeBefore(AllocList *const list, MemNode *const insert, MemNode *const curr) static void __InsertMemNodeBefore(AllocList *const list, MemNode *const insert, MemNode *const curr)
{ {
insert->next = curr; insert->next = curr;
if (curr->prev==NULL) list->head = insert; if (curr->prev==NULL) list->head = insert;
else else
{ {
insert->prev = curr->prev; insert->prev = curr->prev;
curr->prev->next = insert; curr->prev->next = insert;
} }
curr->prev = insert; curr->prev = insert;
} }
@ -259,9 +259,9 @@ static MemNode *__RemoveMemNode(AllocList *const list, MemNode *const node)
if (list->tail != NULL) list->tail->next = NULL; if (list->tail != NULL) list->tail->next = NULL;
else list->head = NULL; else list->head = NULL;
} }
list->len--; list->len--;
return node; return node;
} }
@ -270,12 +270,12 @@ static MemNode *__FindMemNode(AllocList *const list, const size_t bytes)
for (MemNode *node = list->head; node != NULL; node = node->next) for (MemNode *node = list->head; node != NULL; node = node->next)
{ {
if (node->size < bytes) continue; if (node->size < bytes) continue;
// Close in size - reduce fragmentation by not splitting // Close in size - reduce fragmentation by not splitting
else if (node->size <= bytes + MEM_SPLIT_THRESHOLD) return __RemoveMemNode(list, node); else if (node->size <= bytes + MEM_SPLIT_THRESHOLD) return __RemoveMemNode(list, node);
else return __SplitMemNode(node, bytes); else return __SplitMemNode(node, bytes);
} }
return NULL; return NULL;
} }
@ -295,19 +295,19 @@ static void __InsertMemNode(MemPool *const mempool, AllocList *const list, MemNo
mempool->arena.offs += iter->size; mempool->arena.offs += iter->size;
__RemoveMemNode(list, iter); __RemoveMemNode(list, iter);
iter = list->head; iter = list->head;
if (iter == NULL) if (iter == NULL)
{ {
list->head = node; list->head = node;
return; return;
} }
} }
const uintptr_t inode = (uintptr_t)node; const uintptr_t inode = (uintptr_t)node;
const uintptr_t iiter = (uintptr_t)iter; const uintptr_t iiter = (uintptr_t)iter;
const uintptr_t iter_end = iiter + iter->size; const uintptr_t iter_end = iiter + iter->size;
const uintptr_t node_end = inode + node->size; const uintptr_t node_end = inode + node->size;
if (iter == node) return; if (iter == node) return;
else if (iter < node) else if (iter < node)
{ {
@ -317,7 +317,7 @@ static void __InsertMemNode(MemPool *const mempool, AllocList *const list, MemNo
{ {
// if we can coalesce, do so. // if we can coalesce, do so.
iter->size += node->size; iter->size += node->size;
return; return;
} }
else if (iter->next == NULL) else if (iter->next == NULL)
@ -326,8 +326,8 @@ static void __InsertMemNode(MemPool *const mempool, AllocList *const list, MemNo
iter->next = node; iter->next = node;
node->prev = iter; node->prev = iter;
list->len++; list->len++;
return; return;
} }
} }
else if (iter > node) else if (iter > node)
@ -352,7 +352,7 @@ static void __InsertMemNode(MemPool *const mempool, AllocList *const list, MemNo
list->head = node; list->head = node;
list->len++; list->len++;
} }
return; return;
} }
else if ((iter_end == inode) && !is_bucket) else if ((iter_end == inode) && !is_bucket)
@ -385,14 +385,14 @@ MemPool CreateMemPool(const size_t size)
{ {
// Align the mempool size to at least the size of an alloc node. // Align the mempool size to at least the size of an alloc node.
uint8_t *const restrict buf = malloc(size*sizeof *buf); uint8_t *const restrict buf = malloc(size*sizeof *buf);
if (buf==NULL) return mempool; if (buf==NULL) return mempool;
else else
{ {
mempool.arena.size = size; mempool.arena.size = size;
mempool.arena.mem = (uintptr_t)buf; mempool.arena.mem = (uintptr_t)buf;
mempool.arena.offs = mempool.arena.mem + mempool.arena.size; mempool.arena.offs = mempool.arena.mem + mempool.arena.size;
return mempool; return mempool;
} }
} }
@ -401,14 +401,14 @@ MemPool CreateMemPool(const size_t size)
MemPool CreateMemPoolFromBuffer(void *const restrict buf, const size_t size) MemPool CreateMemPoolFromBuffer(void *const restrict buf, const size_t size)
{ {
MemPool mempool = { 0 }; MemPool mempool = { 0 };
if ((size == 0) || (buf == NULL) || (size <= sizeof(MemNode))) return mempool; if ((size == 0) || (buf == NULL) || (size <= sizeof(MemNode))) return mempool;
else else
{ {
mempool.arena.size = size; mempool.arena.size = size;
mempool.arena.mem = (uintptr_t)buf; mempool.arena.mem = (uintptr_t)buf;
mempool.arena.offs = mempool.arena.mem + mempool.arena.size; mempool.arena.offs = mempool.arena.mem + mempool.arena.size;
return mempool; return mempool;
} }
} }
@ -471,7 +471,7 @@ void *MemPoolAlloc(MemPool *const mempool, const size_t size)
// -------------- // --------------
new_mem->next = new_mem->prev = NULL; new_mem->next = new_mem->prev = NULL;
uint8_t *const restrict final_mem = (uint8_t *)new_mem + sizeof *new_mem; uint8_t *const restrict final_mem = (uint8_t *)new_mem + sizeof *new_mem;
return memset(final_mem, 0, new_mem->size - sizeof *new_mem); return memset(final_mem, 0, new_mem->size - sizeof *new_mem);
} }
} }
@ -487,14 +487,14 @@ void *MemPoolRealloc(MemPool *const restrict mempool, void *const ptr, const siz
MemNode *const node = (MemNode *)((uint8_t *)ptr - sizeof *node); MemNode *const node = (MemNode *)((uint8_t *)ptr - sizeof *node);
const size_t NODE_SIZE = sizeof *node; const size_t NODE_SIZE = sizeof *node;
uint8_t *const resized_block = MemPoolAlloc(mempool, size); uint8_t *const resized_block = MemPoolAlloc(mempool, size);
if (resized_block == NULL) return NULL; if (resized_block == NULL) return NULL;
else else
{ {
MemNode *const resized = (MemNode *)(resized_block - sizeof *resized); MemNode *const resized = (MemNode *)(resized_block - sizeof *resized);
memmove(resized_block, ptr, (node->size > resized->size)? (resized->size - NODE_SIZE) : (node->size - NODE_SIZE)); memmove(resized_block, ptr, (node->size > resized->size)? (resized->size - NODE_SIZE) : (node->size - NODE_SIZE));
MemPoolFree(mempool, ptr); MemPoolFree(mempool, ptr);
return resized_block; return resized_block;
} }
} }
@ -503,7 +503,7 @@ void *MemPoolRealloc(MemPool *const restrict mempool, void *const ptr, const siz
void MemPoolFree(MemPool *const restrict mempool, void *const ptr) void MemPoolFree(MemPool *const restrict mempool, void *const ptr)
{ {
const uintptr_t p = (uintptr_t)ptr; const uintptr_t p = (uintptr_t)ptr;
if ((ptr == NULL) || (p - sizeof(MemNode) < mempool->arena.mem)) return; if ((ptr == NULL) || (p - sizeof(MemNode) < mempool->arena.mem)) return;
else else
{ {
@ -556,13 +556,13 @@ void MemPoolReset(MemPool *const mempool)
{ {
mempool->large.head = mempool->large.tail = NULL; mempool->large.head = mempool->large.tail = NULL;
mempool->large.len = 0; mempool->large.len = 0;
for (size_t i = 0; i < MEMPOOL_BUCKET_SIZE; i++) for (size_t i = 0; i < MEMPOOL_BUCKET_SIZE; i++)
{ {
mempool->buckets[i].head = mempool->buckets[i].tail = NULL; mempool->buckets[i].head = mempool->buckets[i].tail = NULL;
mempool->buckets[i].len = 0; mempool->buckets[i].len = 0;
} }
mempool->arena.offs = mempool->arena.mem + mempool->arena.size; mempool->arena.offs = mempool->arena.mem + mempool->arena.size;
} }
@ -573,13 +573,13 @@ void MemPoolReset(MemPool *const mempool)
ObjPool CreateObjPool(const size_t objsize, const size_t len) ObjPool CreateObjPool(const size_t objsize, const size_t len)
{ {
ObjPool objpool = { 0 }; ObjPool objpool = { 0 };
if ((len == 0) || (objsize == 0)) return objpool; if ((len == 0) || (objsize == 0)) return objpool;
else else
{ {
const size_t aligned_size = __AlignSize(objsize, sizeof(size_t)); const size_t aligned_size = __AlignSize(objsize, sizeof(size_t));
uint8_t *const restrict buf = calloc(len, aligned_size); uint8_t *const restrict buf = calloc(len, aligned_size);
if (buf == NULL) return objpool; if (buf == NULL) return objpool;
objpool.objSize = aligned_size; objpool.objSize = aligned_size;
objpool.memSize = objpool.freeBlocks = len; objpool.memSize = objpool.freeBlocks = len;
@ -602,7 +602,7 @@ ObjPool CreateObjPoolFromBuffer(void *const restrict buf, const size_t objsize,
// If the object size isn't large enough to align to a size_t, then we can't use it // If the object size isn't large enough to align to a size_t, then we can't use it
const size_t aligned_size = __AlignSize(objsize, sizeof(size_t)); const size_t aligned_size = __AlignSize(objsize, sizeof(size_t));
if ((buf == NULL) || (len == 0) || (objsize < sizeof(size_t)) || (objsize*len != aligned_size*len)) return objpool; if ((buf == NULL) || (len == 0) || (objsize < sizeof(size_t)) || (objsize*len != aligned_size*len)) return objpool;
else else
{ {
@ -628,7 +628,7 @@ void DestroyObjPool(ObjPool *const restrict objpool)
{ {
void *const restrict ptr = (void *)objpool->mem; void *const restrict ptr = (void *)objpool->mem;
free(ptr); free(ptr);
*objpool = (ObjPool){ 0 }; *objpool = (ObjPool){ 0 };
} }
} }
@ -646,7 +646,7 @@ void *ObjPoolAlloc(ObjPool *const objpool)
// After allocating, we set head to the address of the index that *Head holds. // After allocating, we set head to the address of the index that *Head holds.
// Head = &pool[*Head * pool.objsize]; // Head = &pool[*Head * pool.objsize];
objpool->offs = (objpool->freeBlocks != 0)? objpool->mem + (*block*objpool->objSize) : 0; objpool->offs = (objpool->freeBlocks != 0)? objpool->mem + (*block*objpool->objSize) : 0;
return memset(block, 0, objpool->objSize); return memset(block, 0, objpool->objSize);
} }
else return NULL; else return NULL;
@ -655,7 +655,7 @@ void *ObjPoolAlloc(ObjPool *const objpool)
void ObjPoolFree(ObjPool *const restrict objpool, void *const ptr) void ObjPoolFree(ObjPool *const restrict objpool, void *const ptr)
{ {
uintptr_t block = (uintptr_t)ptr; uintptr_t block = (uintptr_t)ptr;
if ((ptr == NULL) || (block < objpool->mem) || (block > objpool->mem + objpool->memSize*objpool->objSize)) return; if ((ptr == NULL) || (block < objpool->mem) || (block > objpool->mem + objpool->memSize*objpool->objSize)) return;
else else
{ {
@ -687,7 +687,7 @@ void ObjPoolCleanUp(ObjPool *const restrict objpool, void **const restrict ptrre
BiStack CreateBiStack(const size_t len) BiStack CreateBiStack(const size_t len)
{ {
BiStack destack = { 0 }; BiStack destack = { 0 };
if (len == 0) return destack; if (len == 0) return destack;
uint8_t *const buf = malloc(len*sizeof *buf); uint8_t *const buf = malloc(len*sizeof *buf);
@ -696,21 +696,21 @@ BiStack CreateBiStack(const size_t len)
destack.mem = (uintptr_t)buf; destack.mem = (uintptr_t)buf;
destack.front = destack.mem; destack.front = destack.mem;
destack.back = destack.mem + len; destack.back = destack.mem + len;
return destack; return destack;
} }
BiStack CreateBiStackFromBuffer(void *const buf, const size_t len) BiStack CreateBiStackFromBuffer(void *const buf, const size_t len)
{ {
BiStack destack = { 0 }; BiStack destack = { 0 };
if ((len == 0) || (buf == NULL)) return destack; if ((len == 0) || (buf == NULL)) return destack;
else else
{ {
destack.size = len; destack.size = len;
destack.mem = destack.front = (uintptr_t)buf; destack.mem = destack.front = (uintptr_t)buf;
destack.back = destack.mem + len; destack.back = destack.mem + len;
return destack; return destack;
} }
} }
@ -738,7 +738,7 @@ void *BiStackAllocFront(BiStack *const restrict destack, const size_t len)
{ {
uint8_t *const restrict ptr = (uint8_t *)destack->front; uint8_t *const restrict ptr = (uint8_t *)destack->front;
destack->front += ALIGNED_LEN; destack->front += ALIGNED_LEN;
return ptr; return ptr;
} }
} }
@ -756,7 +756,7 @@ void *BiStackAllocBack(BiStack *const restrict destack, const size_t len)
{ {
destack->back -= ALIGNED_LEN; destack->back -= ALIGNED_LEN;
uint8_t *const restrict ptr = (uint8_t *)destack->back; uint8_t *const restrict ptr = (uint8_t *)destack->back;
return ptr; return ptr;
} }
} }

View file

@ -334,7 +334,7 @@ Font LoadFont(const char *fileName)
TRACELOG(LOG_WARNING, "FONT: [%s] Failed to load font texture -> Using default font", fileName); TRACELOG(LOG_WARNING, "FONT: [%s] Failed to load font texture -> Using default font", fileName);
font = GetFontDefault(); font = GetFontDefault();
} }
else else
{ {
SetTextureFilter(font.texture, TEXTURE_FILTER_POINT); // By default we set point filter (best performance) SetTextureFilter(font.texture, TEXTURE_FILTER_POINT); // By default we set point filter (best performance)
TRACELOG(LOG_INFO, "FONT: Data loaded successfully (%i pixel size | %i glyphs)", FONT_TTF_DEFAULT_SIZE, FONT_TTF_DEFAULT_NUMCHARS); TRACELOG(LOG_INFO, "FONT: Data loaded successfully (%i pixel size | %i glyphs)", FONT_TTF_DEFAULT_SIZE, FONT_TTF_DEFAULT_NUMCHARS);

View file

@ -1416,9 +1416,9 @@ void ImageResize(Image *image, int newWidth, int newHeight)
// Check if we can use a fast path on image scaling // Check if we can use a fast path on image scaling
// It can be for 8 bit per channel images with 1 to 4 channels per pixel // It can be for 8 bit per channel images with 1 to 4 channels per pixel
if ((image->format == PIXELFORMAT_UNCOMPRESSED_GRAYSCALE) || if ((image->format == PIXELFORMAT_UNCOMPRESSED_GRAYSCALE) ||
(image->format == PIXELFORMAT_UNCOMPRESSED_GRAY_ALPHA) || (image->format == PIXELFORMAT_UNCOMPRESSED_GRAY_ALPHA) ||
(image->format == PIXELFORMAT_UNCOMPRESSED_R8G8B8) || (image->format == PIXELFORMAT_UNCOMPRESSED_R8G8B8) ||
(image->format == PIXELFORMAT_UNCOMPRESSED_R8G8B8A8)) (image->format == PIXELFORMAT_UNCOMPRESSED_R8G8B8A8))
{ {
int bytesPerPixel = GetPixelDataSize(1, 1, image->format); int bytesPerPixel = GetPixelDataSize(1, 1, image->format);

View file

@ -311,7 +311,7 @@ bool ExportDataAsCode(const char *data, unsigned int size, const char *fileName)
if (success != 0) TRACELOG(LOG_INFO, "FILEIO: [%s] Data as code exported successfully", fileName); if (success != 0) TRACELOG(LOG_INFO, "FILEIO: [%s] Data as code exported successfully", fileName);
else TRACELOG(LOG_WARNING, "FILEIO: [%s] Failed to export data as code", fileName); else TRACELOG(LOG_WARNING, "FILEIO: [%s] Failed to export data as code", fileName);
return success; return success;
} }
// Load text data from file, returns a '\0' terminated string // Load text data from file, returns a '\0' terminated string