Removed all string.h dependencies from core and win32

master
Allen Webster 2019-10-01 16:41:23 -07:00
parent 8a66a157d3
commit 19034b7887
6 changed files with 21 additions and 35 deletions

11
4ed.cpp
View File

@ -190,10 +190,9 @@ interpret_binding_buffer(Models *models, void *buffer, i32 size){
// Initialize Table and User Maps in Temp Buffer
new_mapping.map_id_table = push_array(scratch, i32, user_map_count);
memset(new_mapping.map_id_table, -1, user_map_count*sizeof(i32));
block_fill_u32(new_mapping.map_id_table, user_map_count*sizeof(i32), (u32)(-1));
new_mapping.user_maps = push_array(scratch, Command_Map, user_map_count);
memset(new_mapping.user_maps, 0, user_map_count*sizeof(Command_Map));
new_mapping.user_maps = push_array_zero(scratch, Command_Map, user_map_count);
// Find the Size of Each Map
for (++unit; unit < end; ++unit){
@ -271,12 +270,12 @@ interpret_binding_buffer(Models *models, void *buffer, i32 size){
// Move ID Table Memory and Pointer
i32 *old_table = new_mapping.map_id_table;
new_mapping.map_id_table = push_array(&local_cursor, i32, user_map_count);
memmove(new_mapping.map_id_table, old_table, map_id_table_memsize);
block_copy(new_mapping.map_id_table, old_table, map_id_table_memsize);
// Move User Maps Memory and Pointer
Command_Map *old_maps = new_mapping.user_maps;
new_mapping.user_maps = push_array(&local_cursor, Command_Map, user_map_count);
memmove(new_mapping.user_maps, old_maps, user_maps_memsize);
block_copy(new_mapping.user_maps, old_maps, user_maps_memsize);
// Fill in Command Maps
unit = (Binding_Unit*)buffer;
@ -411,7 +410,7 @@ interpret_binding_buffer(Models *models, void *buffer, i32 size){
{
models->clipboard_change = (Clipboard_Change_Hook_Function*)unit->hook.func;
}break;
case special_hook_get_view_buffer_region:
{
models->get_view_buffer_region = (Get_View_Buffer_Region_Function*)unit->hook.func;

View File

@ -2092,7 +2092,7 @@ Managed_Object_Store_Data(Application_Links *app, Managed_Object object, u32 fir
u32 item_count = object_ptrs.header->count;
if (0 <= first_index && first_index + count <= item_count){
u32 item_size = object_ptrs.header->item_size;
memcpy(ptr + first_index*item_size, mem, count*item_size);
block_copy(ptr + first_index*item_size, mem, count*item_size);
heap_assert_good(&object_ptrs.workspace->heap);
result = true;
}
@ -2111,7 +2111,7 @@ Managed_Object_Load_Data(Application_Links *app, Managed_Object object, u32 firs
u32 item_count = object_ptrs.header->count;
if (0 <= first_index && first_index + count <= item_count){
u32 item_size = object_ptrs.header->item_size;
memcpy(mem_out, ptr + first_index*item_size, count*item_size);
block_copy(mem_out, ptr + first_index*item_size, count*item_size);
heap_assert_good(&object_ptrs.workspace->heap);
result = true;
}

View File

@ -11,9 +11,6 @@
#define REMOVE_OLD_STRING
// TODO(allen): get away from string.h
#include <string.h>
#include "api/4coder_custom.h"
#include "4coder_base_types.h"

View File

@ -112,19 +112,19 @@ eol_convert_in(char *dest, char *src, i32 size){
i32 k = 0;
for (; j < size && src[j] != '\r'; ++j);
memcpy(dest, src, j);
block_copy(dest, src, j);
if (j < size){
k = 1;
++j;
for (i = j; i < size; ++i){
if (src[i] == '\r'){
memcpy(dest + j - k, src + j, i - j);
block_copy(dest + j - k, src + j, i - j);
++k;
j = i+1;
}
}
memcpy(dest + j - k, src + j, i - j);
block_copy(dest + j - k, src + j, i - j);
j = i - k;
}
@ -144,12 +144,12 @@ eol_in_place_convert_in(char *data, i32 size){
++j;
for (i = j; i < size; ++i){
if (data[i] == '\r'){
memmove(data + j - k, data + j, i - j);
block_copy(data + j - k, data + j, i - j);
++k;
j = i+1;
}
}
memmove(data + j - k, data + j, i - j);
block_copy(data + j - k, data + j, i - j);
j = i - k;
}
@ -182,7 +182,7 @@ eol_in_place_convert_out(char *data, i32 size, i32 max, i32 *size_out){
for (; i < size; ++i){
if (data[i] == '\n'){
memmove(data + i + 1, data + i, size - i);
block_copy(data + i + 1, data + i, size - i);
data[i] = '\r';
++i;
++size;

View File

@ -161,12 +161,10 @@ map_init(Command_Map *map, Cursor *cursor, i32 max, i32 parent){
Assert(max >= 6);
Assert(map->commands == 0);
map->parent = parent;
map->commands = push_array(cursor, Command_Binding, max);
map->commands = push_array_zero(cursor, Command_Binding, max);
map->count = 0;
map->max = max;
memset(map->commands, 0, max*sizeof(*map->commands));
memset(map->vanilla_keyboard_default, 0, sizeof(map->vanilla_keyboard_default));
block_zero_array(map->vanilla_keyboard_default);
}
internal b32

View File

@ -24,8 +24,6 @@
#include "4coder_table.h"
#include "api/4coder_version.h"
#include <string.h>
#if defined(FRED_SUPER)
# include "api/4coder_keycodes.h"
# include "api/4coder_default_colors.h"
@ -1500,19 +1498,13 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdS
i32 argc = __argc;
char **argv = __argv;
//
// System Linkage
//
// NOTE(allen): link
sysfunc.font_make_face = ft__font_make_face;
sysfunc.get_texture = gl__get_texture;
sysfunc.fill_texture = gl__fill_texture;
link_system_code();
//
// Memory init
//
// NOTE(allen): memory
Thread_Context _tctx = {};
thread_ctx_init(&_tctx, get_base_allocator_system(&sysfunc));
@ -1522,11 +1514,11 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdS
// TODO(allen): *arena;
target.arena = make_arena_system(&sysfunc);
memset(&plat_settings, 0, sizeof(plat_settings));
block_zero_struct(&plat_settings);
memset(&libraries, 0, sizeof(libraries));
memset(&app, 0, sizeof(app));
memset(&custom_api, 0, sizeof(custom_api));
block_zero_struct(&libraries);
block_zero_struct(&app);
block_zero_struct(&custom_api);
win32vars.cursor_show = MouseCursorShow_Always;
win32vars.prev_cursor_show = MouseCursorShow_Always;