mirror of
https://github.com/Ed94/metadesk.git
synced 2026-08-06 15:48:47 +00:00
memset/memmove overrides
This commit is contained in:
+25
-21
@@ -1,5 +1,26 @@
|
|||||||
// LICENSE AT END OF FILE (MIT).
|
// LICENSE AT END OF FILE (MIT).
|
||||||
|
|
||||||
|
//~/////////////////////////////////////////////////////////////////////////////
|
||||||
|
/////////////////////////// CRT Implementation /////////////////////////////////
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#if MD_DEFAULT_MEMSET
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#if !defined(MD_IMPL_Memset)
|
||||||
|
# define MD_IMPL_Memset MD_CRT_Memset
|
||||||
|
#endif
|
||||||
|
#if !defined(MD_IMPL_Memmove)
|
||||||
|
# define MD_IMPL_Memmove MD_CRT_Memmove
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define MD_CRT_Memset memset
|
||||||
|
#define MD_CRT_Memmove memmove
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
//~/////////////////////////////////////////////////////////////////////////////
|
//~/////////////////////////////////////////////////////////////////////////////
|
||||||
/////////////////////////// Win32 Implementation ///////////////////////////////
|
/////////////////////////// Win32 Implementation ///////////////////////////////
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
@@ -458,22 +479,6 @@ static MD_Node _md_nil_node =
|
|||||||
&_md_nil_node, // ref_target
|
&_md_nil_node, // ref_target
|
||||||
};
|
};
|
||||||
|
|
||||||
//~ Memory Operations
|
|
||||||
|
|
||||||
MD_FUNCTION_IMPL void*
|
|
||||||
MD_MemoryZero(void *memory, MD_u64 size)
|
|
||||||
{
|
|
||||||
memset(memory, 0, size);
|
|
||||||
return(memory);
|
|
||||||
}
|
|
||||||
|
|
||||||
MD_FUNCTION_IMPL void*
|
|
||||||
MD_MemoryCopy(void *dest, void *src, MD_u64 size)
|
|
||||||
{
|
|
||||||
memcpy(dest, src, size);
|
|
||||||
return(dest);
|
|
||||||
}
|
|
||||||
|
|
||||||
//~ Arena Functions
|
//~ Arena Functions
|
||||||
|
|
||||||
MD_FUNCTION_IMPL MD_Arena*
|
MD_FUNCTION_IMPL MD_Arena*
|
||||||
@@ -803,7 +808,7 @@ MD_S8ListConcat(MD_String8List *list, MD_String8List *to_push)
|
|||||||
list->last = to_push->last;
|
list->last = to_push->last;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
MD_MemoryZero(to_push, sizeof(*to_push));
|
MD_MemoryZeroStruct(to_push);
|
||||||
}
|
}
|
||||||
|
|
||||||
MD_FUNCTION_IMPL MD_String8List
|
MD_FUNCTION_IMPL MD_String8List
|
||||||
@@ -1978,7 +1983,7 @@ MD_MessageListConcat(MD_MessageList *list, MD_MessageList *to_push)
|
|||||||
{
|
{
|
||||||
*list = *to_push;
|
*list = *to_push;
|
||||||
}
|
}
|
||||||
MD_MemoryZero(to_push, sizeof(*to_push));
|
MD_MemoryZeroStruct(to_push);
|
||||||
}
|
}
|
||||||
|
|
||||||
MD_FUNCTION_IMPL MD_ParseResult
|
MD_FUNCTION_IMPL MD_ParseResult
|
||||||
@@ -2331,7 +2336,7 @@ MD_ParseOneNode(MD_Arena *arena, MD_String8 string, MD_u64 offset)
|
|||||||
}
|
}
|
||||||
else if(next_token.kind == MD_TokenKind_Newline)
|
else if(next_token.kind == MD_TokenKind_Newline)
|
||||||
{
|
{
|
||||||
MD_MemoryZero(&comment_token, sizeof(comment_token));
|
MD_MemoryZeroStruct(&comment_token);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if((token.kind & MD_TokenGroup_Whitespace) != 0)
|
else if((token.kind & MD_TokenGroup_Whitespace) != 0)
|
||||||
@@ -3391,8 +3396,7 @@ MD_MakeCmdLineFromOptions(MD_Arena *arena, MD_String8List options)
|
|||||||
|
|
||||||
//- rjf: insert the fully parsed option
|
//- rjf: insert the fully parsed option
|
||||||
{
|
{
|
||||||
MD_CmdLineOption *opt = MD_PushArray(arena, MD_CmdLineOption, 1);
|
MD_CmdLineOption *opt = MD_PushArrayZero(arena, MD_CmdLineOption, 1);
|
||||||
MD_MemoryZero(opt, sizeof(*opt));
|
|
||||||
opt->name = option_name;
|
opt->name = option_name;
|
||||||
opt->values = option_values;
|
opt->values = option_values;
|
||||||
if(cmdln.last_option == 0)
|
if(cmdln.last_option == 0)
|
||||||
|
|||||||
+15
-7
@@ -5,9 +5,16 @@
|
|||||||
#ifndef MD_H
|
#ifndef MD_H
|
||||||
#define MD_H
|
#define MD_H
|
||||||
|
|
||||||
|
// TODO(rjf): implicitly-delimited sets are not having their separator flags
|
||||||
|
// appropriately set
|
||||||
|
|
||||||
/* NOTE(allen): Notes on overrides/macro options:
|
/* NOTE(allen): Notes on overrides/macro options:
|
||||||
**
|
**
|
||||||
** Overridable :
|
** Overridable :
|
||||||
|
** "memset" ** REQUIRED (default crt-based implementation available)
|
||||||
|
** #define MD_IMPL_Memset (void*, int, MD_u64) -> void*
|
||||||
|
** #define MD_IMPL_Memmove (void*, void*, MD_u64) -> void*
|
||||||
|
**
|
||||||
** "file iteration" ** OPTIONAL
|
** "file iteration" ** OPTIONAL
|
||||||
** #define MD_IMPL_FileIterBegin (MD_FileIter*, MD_String8) -> MD_b32
|
** #define MD_IMPL_FileIterBegin (MD_FileIter*, MD_String8) -> MD_b32
|
||||||
** #define MD_IMPL_FileIterNext (MD_Arena*, MD_FileIter*) -> MD_FileInfo
|
** #define MD_IMPL_FileIterNext (MD_Arena*, MD_FileIter*) -> MD_FileInfo
|
||||||
@@ -37,6 +44,7 @@
|
|||||||
**
|
**
|
||||||
** Default Implementation Controls
|
** Default Implementation Controls
|
||||||
** These controls default to '1' i.e. 'enabled'
|
** These controls default to '1' i.e. 'enabled'
|
||||||
|
** #define MD_DEFAULT_MEMSET -> construct "memset" from CRT
|
||||||
** #define MD_DEFAULT_FILE_ITER -> construct "file iteration" from OS headers
|
** #define MD_DEFAULT_FILE_ITER -> construct "file iteration" from OS headers
|
||||||
** #define MD_DEFAULT_MEMORY -> construct "low level memory" from OS headers
|
** #define MD_DEFAULT_MEMORY -> construct "low level memory" from OS headers
|
||||||
** #define MD_DEFAULT_ARENA -> construct "arena" from "low level memory"
|
** #define MD_DEFAULT_ARENA -> construct "arena" from "low level memory"
|
||||||
@@ -44,10 +52,10 @@
|
|||||||
**
|
**
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// TODO(rjf): implicitly-delimited sets are not having their separator flags
|
|
||||||
// appropriately set
|
|
||||||
|
|
||||||
//~ Set default values for controls
|
//~ Set default values for controls
|
||||||
|
#if !defined(MD_DEFAULT_MEMSET)
|
||||||
|
# define MD_DEFAULT_MEMSET 1
|
||||||
|
#endif
|
||||||
#if !defined(MD_DEFAULT_FILE_ITER)
|
#if !defined(MD_DEFAULT_FILE_ITER)
|
||||||
# define MD_DEFAULT_FILE_ITER 1
|
# define MD_DEFAULT_FILE_ITER 1
|
||||||
#endif
|
#endif
|
||||||
@@ -293,10 +301,8 @@
|
|||||||
#define MD_GLOBAL static
|
#define MD_GLOBAL static
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <string.h>
|
|
||||||
#define STB_SPRINTF_DECORATE(name) md_stbsp_##name
|
#define STB_SPRINTF_DECORATE(name) md_stbsp_##name
|
||||||
#include "md_stb_sprintf.h"
|
#include "md_stb_sprintf.h"
|
||||||
|
|
||||||
@@ -774,8 +780,10 @@ struct MD_FileIter
|
|||||||
|
|
||||||
//~ Memory Operations
|
//~ Memory Operations
|
||||||
|
|
||||||
MD_FUNCTION void* MD_MemoryZero(void *memory, MD_u64 size);
|
#define MD_MemorySet(p,v,z) (MD_IMPL_Memset(p,v,z))
|
||||||
MD_FUNCTION void* MD_MemoryCopy(void *dst, void *src, MD_u64 size);
|
#define MD_MemoryZero(p,z) (MD_IMPL_Memset(p,0,z))
|
||||||
|
#define MD_MemoryZeroStruct(p) (MD_IMPL_Memset(p,0,sizeof(*(p))))
|
||||||
|
#define MD_MemoryCopy(d,s,z) (MD_IMPL_Memmove(d,s,z))
|
||||||
|
|
||||||
//~ Arena Functions
|
//~ Arena Functions
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user