Skip to content
This repository has been archived by the owner on Aug 21, 2020. It is now read-only.

Commit

Permalink
Fix another critical bug(File download above 15 mb should not fail).
Browse files Browse the repository at this point in the history
  • Loading branch information
hax0kartik committed Apr 21, 2017
1 parent 161da24 commit 8377014
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
10 changes: 5 additions & 5 deletions source/download.cpp
Expand Up @@ -14,7 +14,7 @@ Result http_download(string url,string loca)
Result ret = 0;
u32 statuscode=0;
u32 contentsize=0, readsize=0, size=0;
u8* buf;u8 *lastbuf;
u64* buf;u64 *lastbuf;
char a[2048];
string strNew;
httpcContext context;
Expand Down Expand Up @@ -98,7 +98,7 @@ Result http_download(string url,string loca)
cout<<"\x1b[33;1msize(may be wrong) : \x1b[37;1m"<<contentsize<<endl;
gfxFlushBuffers();
gfxSwapBuffers();
buf = (u8*)malloc(0x1000);
buf = (u64*)malloc(0x1000);
if(buf==NULL){
httpcCloseContext(&context);
return 1;
Expand All @@ -108,7 +108,7 @@ Result http_download(string url,string loca)
bar.print();
do {
// This download loop resizes the buffer as data is read.
ret = httpcDownloadData(&context, buf+size, 0x1000, &readsize);
ret = httpcDownloadData(&context,(u8*) buf+size, 0x1000, &readsize);
size += readsize;
if(contentsize!=0){
bar.update(readsize);
Expand All @@ -117,7 +117,7 @@ Result http_download(string url,string loca)
else{ ; }
if (ret == (s32)HTTPC_RESULTCODE_DOWNLOADPENDING){
lastbuf = buf; // Save the old pointer, in case realloc() fails.
buf = (u8*)realloc(buf, size + 0x1000);
buf = (u64*)realloc(buf, size + 0x1000);
if(buf==NULL){
httpcCloseContext(&context);
free(lastbuf);
Expand All @@ -134,7 +134,7 @@ Result http_download(string url,string loca)

// Resize the buffer back down to our actual final size
lastbuf = buf;
buf = (u8*)realloc(buf, size);
buf = (u64*)realloc(buf, size);
if(buf==NULL){ // realloc() failed.
httpcCloseContext(&context);
free(lastbuf);
Expand Down
2 changes: 1 addition & 1 deletion source/fs.cpp
Expand Up @@ -6,7 +6,7 @@
#include <cstdio>
#include <iomanip>
using namespace std;
void wf(string a,uint8_t* b, size_t size)
void wf(string a,uint64_t* b, size_t size)
{
cout<<"Writing the file please wait..."<<endl;
FILE *fp;
Expand Down
2 changes: 1 addition & 1 deletion source/include/fs.hpp
@@ -1,4 +1,4 @@
#include <string>
#include <cstring>
void wf(std::string a,uint8_t *b,size_t size);
void wf(std::string a,uint64_t *b,size_t size);
std::string rf(std::string a);
2 changes: 1 addition & 1 deletion source/main.cpp
Expand Up @@ -64,7 +64,7 @@ int main()
cout<<"Xplorer";
xplorer();
cout<<"\x1b[2J";
wf("sdmc:/multi.cfg",(u8*)current_path,strlen(current_path));
wf("sdmc:/multi.cfg",(u64*)current_path,strlen(current_path));
cout<<"Current path:"<<current_path;
menu();
}
Expand Down

0 comments on commit 8377014

Please sign in to comment.