Skip to content

Commit

Permalink
memcpy used
Browse files Browse the repository at this point in the history
  • Loading branch information
heweitykc committed Aug 27, 2014
1 parent 3743754 commit 648e412
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 11 deletions.
13 changes: 3 additions & 10 deletions proj/pkgutil/Win32Project2/pkgutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,24 +30,17 @@ void pkgUtil::pkg(netpack *pack, char* out)
out[4] = *(cp + 3);

int i = 0;
while (i < pack->len){
out[i + pkgUtil::HEAD_SIZE] = pack->raw[i];
i++;
}
memcpy(out + pkgUtil::HEAD_SIZE, pack->raw, pack->len);
}

void pkgUtil::unpkg(const char* in, netpack *pack)
{
int len = (*(in + 3)) + ((*(in + 2)) << 8) + ((*(in + 1)) << 16) + ((*in) << 24);
int cmd = (*(in + 7)) + ((*(in + 6)) << 8) + ((*(in + 5)) << 16) + ((*(in+4)) << 24);
int cmd = (*(in + 7)) + ((*(in + 6)) << 8) + ((*(in + 5)) << 16) + ((*(in + 4)) << 24);
pack->raw = new char[len];
pack->len = len;
pack->cmd = cmd;
int i = 0;
while (i < len){
pack->raw[i] = in[i + pkgUtil::HEAD_SIZE];
i++;
}
memcpy(pack->raw, in + pkgUtil::HEAD_SIZE, len);
}

pkgUtil::pkgUtil()
Expand Down
2 changes: 1 addition & 1 deletion proj/pkgutiltest/pkgutiltest.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>false</SDLCheck>
<AdditionalIncludeDirectories>E:\newcode\cpp11_study\proj\pkgutil\Win32Project2;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>..\pkgutil\Win32Project2;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
Expand Down

0 comments on commit 648e412

Please sign in to comment.