Skip to content

Commit d68b18d

Browse files
committed
Memory Utils
1 parent 7c6f68d commit d68b18d

File tree

5 files changed

+222
-0
lines changed

5 files changed

+222
-0
lines changed
Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<ItemGroup Label="ProjectConfigurations">
4+
<ProjectConfiguration Include="Debug|Win32">
5+
<Configuration>Debug</Configuration>
6+
<Platform>Win32</Platform>
7+
</ProjectConfiguration>
8+
<ProjectConfiguration Include="Release|Win32">
9+
<Configuration>Release</Configuration>
10+
<Platform>Win32</Platform>
11+
</ProjectConfiguration>
12+
<ProjectConfiguration Include="Debug|x64">
13+
<Configuration>Debug</Configuration>
14+
<Platform>x64</Platform>
15+
</ProjectConfiguration>
16+
<ProjectConfiguration Include="Release|x64">
17+
<Configuration>Release</Configuration>
18+
<Platform>x64</Platform>
19+
</ProjectConfiguration>
20+
</ItemGroup>
21+
<PropertyGroup Label="Globals">
22+
<VCProjectVersion>16.0</VCProjectVersion>
23+
<Keyword>Win32Proj</Keyword>
24+
<ProjectGuid>{4f53f917-5003-49b6-bee8-b8837cefd088}</ProjectGuid>
25+
<RootNamespace>My03MemoryUtils</RootNamespace>
26+
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
27+
</PropertyGroup>
28+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
29+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
30+
<ConfigurationType>Application</ConfigurationType>
31+
<UseDebugLibraries>true</UseDebugLibraries>
32+
<PlatformToolset>v143</PlatformToolset>
33+
<CharacterSet>Unicode</CharacterSet>
34+
</PropertyGroup>
35+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
36+
<ConfigurationType>Application</ConfigurationType>
37+
<UseDebugLibraries>false</UseDebugLibraries>
38+
<PlatformToolset>v143</PlatformToolset>
39+
<WholeProgramOptimization>true</WholeProgramOptimization>
40+
<CharacterSet>Unicode</CharacterSet>
41+
</PropertyGroup>
42+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
43+
<ConfigurationType>Application</ConfigurationType>
44+
<UseDebugLibraries>true</UseDebugLibraries>
45+
<PlatformToolset>v143</PlatformToolset>
46+
<CharacterSet>Unicode</CharacterSet>
47+
</PropertyGroup>
48+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
49+
<ConfigurationType>Application</ConfigurationType>
50+
<UseDebugLibraries>false</UseDebugLibraries>
51+
<PlatformToolset>v143</PlatformToolset>
52+
<WholeProgramOptimization>true</WholeProgramOptimization>
53+
<CharacterSet>Unicode</CharacterSet>
54+
</PropertyGroup>
55+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
56+
<ImportGroup Label="ExtensionSettings">
57+
</ImportGroup>
58+
<ImportGroup Label="Shared">
59+
</ImportGroup>
60+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
61+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
62+
</ImportGroup>
63+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
64+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
65+
</ImportGroup>
66+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
67+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
68+
</ImportGroup>
69+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
70+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
71+
</ImportGroup>
72+
<PropertyGroup Label="UserMacros" />
73+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
74+
<OutDir>$(SolutionDir)build\bin\$(PlatformShortName)-$(Configuration)\</OutDir>
75+
<IntDir>$(SolutionDir)build\obj\$(PlatformShortName)-$(Configuration)\$(ProjectName)\</IntDir>
76+
<TargetName>MemoryUtils</TargetName>
77+
</PropertyGroup>
78+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
79+
<OutDir>$(SolutionDir)build\bin\$(PlatformShortName)-$(Configuration)\</OutDir>
80+
<IntDir>$(SolutionDir)build\obj\$(PlatformShortName)-$(Configuration)\$(ProjectName)\</IntDir>
81+
<TargetName>MemoryUtils</TargetName>
82+
</PropertyGroup>
83+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
84+
<OutDir>$(SolutionDir)build\bin\$(PlatformShortName)-$(Configuration)\</OutDir>
85+
<IntDir>$(SolutionDir)build\obj\$(PlatformShortName)-$(Configuration)\$(ProjectName)\</IntDir>
86+
<TargetName>MemoryUtils</TargetName>
87+
</PropertyGroup>
88+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
89+
<OutDir>$(SolutionDir)build\bin\$(PlatformShortName)-$(Configuration)\</OutDir>
90+
<IntDir>$(SolutionDir)build\obj\$(PlatformShortName)-$(Configuration)\$(ProjectName)\</IntDir>
91+
<TargetName>MemoryUtils</TargetName>
92+
</PropertyGroup>
93+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
94+
<ClCompile>
95+
<WarningLevel>Level3</WarningLevel>
96+
<SDLCheck>true</SDLCheck>
97+
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
98+
<ConformanceMode>true</ConformanceMode>
99+
</ClCompile>
100+
<Link>
101+
<SubSystem>Console</SubSystem>
102+
<GenerateDebugInformation>true</GenerateDebugInformation>
103+
</Link>
104+
</ItemDefinitionGroup>
105+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
106+
<ClCompile>
107+
<WarningLevel>Level3</WarningLevel>
108+
<FunctionLevelLinking>true</FunctionLevelLinking>
109+
<IntrinsicFunctions>true</IntrinsicFunctions>
110+
<SDLCheck>true</SDLCheck>
111+
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
112+
<ConformanceMode>true</ConformanceMode>
113+
</ClCompile>
114+
<Link>
115+
<SubSystem>Console</SubSystem>
116+
<EnableCOMDATFolding>true</EnableCOMDATFolding>
117+
<OptimizeReferences>true</OptimizeReferences>
118+
<GenerateDebugInformation>true</GenerateDebugInformation>
119+
</Link>
120+
</ItemDefinitionGroup>
121+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
122+
<ClCompile>
123+
<WarningLevel>Level3</WarningLevel>
124+
<SDLCheck>true</SDLCheck>
125+
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
126+
<ConformanceMode>true</ConformanceMode>
127+
</ClCompile>
128+
<Link>
129+
<SubSystem>Console</SubSystem>
130+
<GenerateDebugInformation>true</GenerateDebugInformation>
131+
</Link>
132+
</ItemDefinitionGroup>
133+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
134+
<ClCompile>
135+
<WarningLevel>Level3</WarningLevel>
136+
<FunctionLevelLinking>true</FunctionLevelLinking>
137+
<IntrinsicFunctions>true</IntrinsicFunctions>
138+
<SDLCheck>true</SDLCheck>
139+
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
140+
<ConformanceMode>true</ConformanceMode>
141+
</ClCompile>
142+
<Link>
143+
<SubSystem>Console</SubSystem>
144+
<EnableCOMDATFolding>true</EnableCOMDATFolding>
145+
<OptimizeReferences>true</OptimizeReferences>
146+
<GenerateDebugInformation>true</GenerateDebugInformation>
147+
</Link>
148+
</ItemDefinitionGroup>
149+
<ItemGroup>
150+
<ClCompile Include="MemoryUtils.c" />
151+
</ItemGroup>
152+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
153+
<ImportGroup Label="ExtensionTargets">
154+
</ImportGroup>
155+
</Project>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<ItemGroup>
4+
<Filter Include="Source Files">
5+
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
6+
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
7+
</Filter>
8+
<Filter Include="Header Files">
9+
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
10+
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
11+
</Filter>
12+
<Filter Include="Resource Files">
13+
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
14+
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
15+
</Filter>
16+
</ItemGroup>
17+
<ItemGroup>
18+
<ClCompile Include="MemoryUtils.c">
19+
<Filter>Source Files</Filter>
20+
</ClCompile>
21+
</ItemGroup>
22+
</Project>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<ShowAllFiles>true</ShowAllFiles>
5+
</PropertyGroup>
6+
</Project>

03_MemoryUtils/MemoryUtils.c

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#include <stdio.h>
2+
#include <stdint.h>
3+
#include <stdlib.h>
4+
5+
#include <string.h>
6+
7+
int main()
8+
{
9+
int32_t arrayA[32];
10+
int32_t arrayB[32];
11+
12+
// Init arrays
13+
for (int32_t i = 0; i < 32; i++)
14+
{
15+
arrayA[i] = i * 11;
16+
}
17+
memset(arrayB, 0xFF, 32 * sizeof(int32_t));
18+
19+
// Compared arrays
20+
int32_t abEqual = memcmp(arrayA, arrayB, 32 * sizeof(int32_t)) == 0;
21+
printf("Arrays equal bevore copy: %i; ", abEqual);
22+
23+
// Copy arrays
24+
memcpy(arrayB, arrayA, 32 * sizeof(int32_t));
25+
26+
// Compared arrays
27+
abEqual = memcmp(arrayA, arrayB, 32 * sizeof(int32_t)) == 0;
28+
printf("Arrays equal after copy: %i", abEqual);
29+
}

C-Cpp-Tutorial.sln

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "E01_Functions", "Exercises\
1111
EndProject
1212
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "02_Pointers", "02_Pointers\02_Pointers.vcxproj", "{8412A5E2-BFB4-4EEA-98C1-52EC94A8F7C5}"
1313
EndProject
14+
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "03_MemoryUtils", "03_MemoryUtils\03_MemoryUtils.vcxproj", "{4F53F917-5003-49B6-BEE8-B8837CEFD088}"
15+
EndProject
1416
Global
1517
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1618
Debug|x64 = Debug|x64
@@ -43,6 +45,14 @@ Global
4345
{8412A5E2-BFB4-4EEA-98C1-52EC94A8F7C5}.Release|x64.Build.0 = Release|x64
4446
{8412A5E2-BFB4-4EEA-98C1-52EC94A8F7C5}.Release|x86.ActiveCfg = Release|Win32
4547
{8412A5E2-BFB4-4EEA-98C1-52EC94A8F7C5}.Release|x86.Build.0 = Release|Win32
48+
{4F53F917-5003-49B6-BEE8-B8837CEFD088}.Debug|x64.ActiveCfg = Debug|x64
49+
{4F53F917-5003-49B6-BEE8-B8837CEFD088}.Debug|x64.Build.0 = Debug|x64
50+
{4F53F917-5003-49B6-BEE8-B8837CEFD088}.Debug|x86.ActiveCfg = Debug|Win32
51+
{4F53F917-5003-49B6-BEE8-B8837CEFD088}.Debug|x86.Build.0 = Debug|Win32
52+
{4F53F917-5003-49B6-BEE8-B8837CEFD088}.Release|x64.ActiveCfg = Release|x64
53+
{4F53F917-5003-49B6-BEE8-B8837CEFD088}.Release|x64.Build.0 = Release|x64
54+
{4F53F917-5003-49B6-BEE8-B8837CEFD088}.Release|x86.ActiveCfg = Release|Win32
55+
{4F53F917-5003-49B6-BEE8-B8837CEFD088}.Release|x86.Build.0 = Release|Win32
4656
EndGlobalSection
4757
GlobalSection(SolutionProperties) = preSolution
4858
HideSolutionNode = FALSE

0 commit comments

Comments
 (0)