Avoid more stdlib functions with FreeType

This commit is contained in:
UnknownShadow200 2024-05-31 08:03:54 +10:00
parent bbda33cd5a
commit cbaf42c886
7 changed files with 61 additions and 18 deletions

View file

@ -25,5 +25,6 @@ runs:
steps:
- name: Notify failure
shell: sh
if: ${{ inputs.WEBHOOK_URL != '' }}
run: |
curl ${{ inputs.WEBHOOK_URL }} -H "Accept: application/json" -H "Content-Type:application/json" -X POST --data "{\"username\": \"${{ inputs.BOT_USERNAME }}\", \"avatar_url\": \"${{ inputs.BOT_AVATAR }}\", \"content\": \"${{ inputs.NOTIFY_MESSAGE }}\" }"

View file

@ -152,13 +152,13 @@ CC_API void* Mem_Realloc(void* mem, cc_uint32 numElems, cc_uint32 elemsSize, con
CC_API void Mem_Free(void* mem);
/* Sets the contents of a block of memory to the given value. */
void* Mem_Set(void* dst, cc_uint8 value, cc_uint32 numBytes);
void* Mem_Set(void* dst, cc_uint8 value, unsigned numBytes);
/* Copies a block of memory to another block of memory. */
/* NOTE: These blocks MUST NOT overlap. */
void* Mem_Copy(void* dst, const void* src, cc_uint32 numBytes);
void* Mem_Copy(void* dst, const void* src, unsigned numBytes);
/* Moves a block of memory to another block of memory. */
/* NOTE: These blocks can overlap. */
void* Mem_Move(void* dst, const void* src, cc_uint32 numBytes);
void* Mem_Move(void* dst, const void* src, unsigned numBytes);
/* Returns non-zero if the two given blocks of memory have equal contents. */
int Mem_Equal(const void* a, const void* b, cc_uint32 numBytes);

View file

@ -73,9 +73,9 @@ cc_bool Platform_SingleProcess;
/*########################################################################################################################*
*---------------------------------------------------------Memory----------------------------------------------------------*
*#########################################################################################################################*/
void* Mem_Set(void* dst, cc_uint8 value, cc_uint32 numBytes) { return memset( dst, value, numBytes); }
void* Mem_Copy(void* dst, const void* src, cc_uint32 numBytes) { return memcpy( dst, src, numBytes); }
void* Mem_Move(void* dst, const void* src, cc_uint32 numBytes) { return memmove(dst, src, numBytes); }
void* Mem_Set(void* dst, cc_uint8 value, unsigned numBytes) { return memset( dst, value, numBytes); }
void* Mem_Copy(void* dst, const void* src, unsigned numBytes) { return memcpy( dst, src, numBytes); }
void* Mem_Move(void* dst, const void* src, unsigned numBytes) { return memmove(dst, src, numBytes); }
void* Mem_TryAlloc(cc_uint32 numElems, cc_uint32 elemsSize) {
cc_uint32 size = CalcMemSize(numElems, elemsSize);

View file

@ -43,9 +43,9 @@ cc_bool Platform_SingleProcess;
/*########################################################################################################################*
*---------------------------------------------------------Memory----------------------------------------------------------*
*#########################################################################################################################*/
void* Mem_Set(void* dst, cc_uint8 value, cc_uint32 numBytes) { return memset( dst, value, numBytes); }
void* Mem_Copy(void* dst, const void* src, cc_uint32 numBytes) { return memcpy( dst, src, numBytes); }
void* Mem_Move(void* dst, const void* src, cc_uint32 numBytes) { return memmove(dst, src, numBytes); }
void* Mem_Set(void* dst, cc_uint8 value, unsigned numBytes) { return memset( dst, value, numBytes); }
void* Mem_Copy(void* dst, const void* src, unsigned numBytes) { return memcpy( dst, src, numBytes); }
void* Mem_Move(void* dst, const void* src, unsigned numBytes) { return memmove(dst, src, numBytes); }
void* Mem_TryAlloc(cc_uint32 numElems, cc_uint32 elemsSize) {
cc_uint32 size = CalcMemSize(numElems, elemsSize);
@ -749,7 +749,6 @@ const struct UpdaterInfo Updater_Info = { "", 1, { { "Direct3D11", "cc-arm32-d3d
#else
const struct UpdaterInfo Updater_Info = { "&eCompile latest source code to update", 0 };
#endif
};
cc_bool Updater_Clean(void) {
return DeleteFile(UPDATE_TMP) || GetLastError() == ERROR_FILE_NOT_FOUND;

View file

@ -288,6 +288,45 @@ size_t cc_strlen(const char* a) {
return i;
}
char* cc_strstr(const char* str, const char* substr) {
const char* a;
const char* b;
if (!substr[0]) return (char*)str;
for (; *str; str++)
{
/* Definitely not a match */
if (*str != substr[0]) continue;
/* It's a possible match */
if (cc_strcmp(str, substr) == 0) return (char*)str;
}
return NULL;
}
int cc_memcmp(const void* ptrA, const void* ptrB, size_t num) {
const unsigned char* a = (const unsigned char*)ptrA;
const unsigned char* b = (const unsigned char*)ptrB;
for (; num > 0; num--, a++, b++)
{
if (*a != *b) return *a - *b;
}
return 0;
}
void* cc_memchr(const void* ptr, int ch, size_t num) {
const char* a = (const char*)ptr;
for (; num > 0; num--, a++)
{
if (*a == ch) return a;
}
return NULL;
}
static FT_Library ft_lib;
static struct FT_MemoryRec_ ft_mem;
static struct StringsBuffer font_list;

View file

@ -4,9 +4,9 @@ cc_bool Platform_SingleProcess = true;
/*########################################################################################################################*
*---------------------------------------------------------Memory----------------------------------------------------------*
*#########################################################################################################################*/
void* Mem_Set(void* dst, cc_uint8 value, cc_uint32 numBytes) { return memset( dst, value, numBytes); }
void* Mem_Copy(void* dst, const void* src, cc_uint32 numBytes) { return memcpy( dst, src, numBytes); }
void* Mem_Move(void* dst, const void* src, cc_uint32 numBytes) { return memmove(dst, src, numBytes); }
void* Mem_Set(void* dst, cc_uint8 value, unsigned numBytes) { return memset( dst, value, numBytes); }
void* Mem_Copy(void* dst, const void* src, unsigned numBytes) { return memcpy( dst, src, numBytes); }
void* Mem_Move(void* dst, const void* src, unsigned numBytes) { return memmove(dst, src, numBytes); }
void* Mem_TryAlloc(cc_uint32 numElems, cc_uint32 elemsSize) {
cc_uint32 size = CalcMemSize(numElems, elemsSize);

View file

@ -77,19 +77,23 @@
#include <string.h>
/* ClassiCube functions to avoid stdlib */
extern int cc_strncmp(const char* a, const char* b, size_t maxCount);
extern int cc_strcmp( const char* a, const char* b);
extern int cc_strncmp(const char* a, const char* b, size_t maxCount);
extern int cc_strcmp(const char* a, const char* b);
extern size_t cc_strlen(const char* a);
extern char* cc_strstr(const char* str, const char* substr);
#define ft_memchr memchr
#define ft_memcmp memcmp
extern int cc_memcmp(const void* ptrA, const void* ptrB, size_t num);
extern void* cc_memchr(const void* ptr, int ch, size_t num);
#define ft_memchr cc_memchr
#define ft_memcmp cc_memcmp
#define ft_memcpy memcpy
#define ft_memmove memmove
#define ft_memset memset
#define ft_strcmp cc_strcmp
#define ft_strlen cc_strlen
#define ft_strncmp cc_strncmp
#define ft_strstr strstr
#define ft_strstr cc_strstr
/**********************************************************************/