Format source code

This commit is contained in:
Jordan Bancino 2022-10-13 09:09:26 -04:00
parent 2df0cd9d26
commit 945acd1adf
7 changed files with 317 additions and 270 deletions

View file

@ -1,3 +1,26 @@
/*
* Copyright (C) 2022 Jordan Bancino <@jordan:bancino.net>
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation files
* (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#include <Memory.h> #include <Memory.h>
#include <stdio.h> #include <stdio.h>
@ -18,7 +41,7 @@ struct MemoryInfo
static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER; static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
static MemoryInfo *lastAllocation = NULL; static MemoryInfo *lastAllocation = NULL;
static void (*hook)(MemoryAction, MemoryInfo *, void *) = NULL; static void (*hook) (MemoryAction, MemoryInfo *, void *) = NULL;
static void *hookArgs = NULL; static void *hookArgs = NULL;
void * void *
@ -217,7 +240,7 @@ MemoryInfoGet(void *p)
} }
size_t size_t
MemoryInfoGetSize(MemoryInfo *a) MemoryInfoGetSize(MemoryInfo * a)
{ {
if (!a) if (!a)
{ {
@ -228,7 +251,7 @@ MemoryInfoGetSize(MemoryInfo *a)
} }
const char * const char *
MemoryInfoGetFile(MemoryInfo *a) MemoryInfoGetFile(MemoryInfo * a)
{ {
if (!a) if (!a)
{ {
@ -239,7 +262,7 @@ MemoryInfoGetFile(MemoryInfo *a)
} }
const char * const char *
MemoryInfoGetFunc(MemoryInfo *a) MemoryInfoGetFunc(MemoryInfo * a)
{ {
if (!a) if (!a)
{ {
@ -250,7 +273,7 @@ MemoryInfoGetFunc(MemoryInfo *a)
} }
int int
MemoryInfoGetLine(MemoryInfo *a) MemoryInfoGetLine(MemoryInfo * a)
{ {
if (!a) if (!a)
{ {
@ -261,7 +284,7 @@ MemoryInfoGetLine(MemoryInfo *a)
} }
void * void *
MemoryInfoGetPointer(MemoryInfo *a) MemoryInfoGetPointer(MemoryInfo * a)
{ {
if (!a) if (!a)
{ {
@ -272,7 +295,7 @@ MemoryInfoGetPointer(MemoryInfo *a)
} }
void void
MemoryIterate(void (*iterFunc)(MemoryInfo *, void *), void *args) MemoryIterate(void (*iterFunc) (MemoryInfo *, void *), void *args)
{ {
MemoryInfo *a; MemoryInfo *a;
@ -289,7 +312,7 @@ MemoryIterate(void (*iterFunc)(MemoryInfo *, void *), void *args)
} }
void void
MemoryHook(void (*memHook)(MemoryAction, MemoryInfo *, void *), void *args) MemoryHook(void (*memHook) (MemoryAction, MemoryInfo *, void *), void *args)
{ {
pthread_mutex_lock(&lock); pthread_mutex_lock(&lock);
hook = memHook; hook = memHook;

View file

@ -41,7 +41,8 @@
#include <HttpServer.h> #include <HttpServer.h>
#include <Matrix.h> #include <Matrix.h>
static void TelodendriaMemoryHook(MemoryAction a, MemoryInfo *i, void *args) static void
TelodendriaMemoryHook(MemoryAction a, MemoryInfo * i, void *args)
{ {
LogConfig *lc = (LogConfig *) args; LogConfig *lc = (LogConfig *) args;
char *action; char *action;
@ -69,7 +70,7 @@ static void TelodendriaMemoryHook(MemoryAction a, MemoryInfo *i, void *args)
} }
static void static void
TelodendriaMemoryIterator(MemoryInfo *i, void *args) TelodendriaMemoryIterator(MemoryInfo * i, void *args)
{ {
LogConfig *lc = (LogConfig *) args; LogConfig *lc = (LogConfig *) args;

View file

@ -34,7 +34,7 @@ extern void
HashMapMaxLoadSet(HashMap *, float); HashMapMaxLoadSet(HashMap *, float);
extern void extern void
HashMapFunctionSet(HashMap *, unsigned long (*) (const char *)); HashMapFunctionSet(HashMap *, unsigned long (*) (const char *));
extern void * extern void *
HashMapSet(HashMap *, char *, void *); HashMapSet(HashMap *, char *, void *);

View file

@ -1,3 +1,26 @@
/*
* Copyright (C) 2022 Jordan Bancino <@jordan:bancino.net>
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation files
* (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#ifndef TELODENDRIA_MEMORY_H #ifndef TELODENDRIA_MEMORY_H
#define TELODENDRIA_MEMORY_H #define TELODENDRIA_MEMORY_H
@ -23,16 +46,16 @@ extern void MemoryFree(void *);
extern size_t MemoryAllocated(void); extern size_t MemoryAllocated(void);
extern void MemoryFreeAll(void); extern void MemoryFreeAll(void);
extern MemoryInfo * MemoryInfoGet(void *); extern MemoryInfo *MemoryInfoGet(void *);
extern size_t MemoryInfoGetSize(MemoryInfo *); extern size_t MemoryInfoGetSize(MemoryInfo *);
extern const char * MemoryInfoGetFile(MemoryInfo *); extern const char *MemoryInfoGetFile(MemoryInfo *);
extern const char * MemoryInfoGetFunc(MemoryInfo *); extern const char *MemoryInfoGetFunc(MemoryInfo *);
extern int MemoryInfoGetLine(MemoryInfo *); extern int MemoryInfoGetLine(MemoryInfo *);
extern void * MemoryInfoGetPointer(MemoryInfo *); extern void *MemoryInfoGetPointer(MemoryInfo *);
extern void MemoryIterate(void (*)(MemoryInfo *, void *), void *); extern void MemoryIterate(void (*) (MemoryInfo *, void *), void *);
extern void MemoryHook(void (*)(MemoryAction, MemoryInfo *, void *), void *); extern void MemoryHook(void (*) (MemoryAction, MemoryInfo *, void *), void *);
#endif #endif