Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
TLMSP curl
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
CYBER - Cyber Security
TS 103 523 MSP
TLMSP
TLMSP curl
Commits
a40b55d5
Commit
a40b55d5
authored
24 years ago
by
Daniel Stenberg
Browse files
Options
Downloads
Patches
Plain Diff
Added 5.2 How can I receive all data into a large memory chunk?
parent
5aa5ecb2
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
docs/FAQ
+36
-1
36 additions, 1 deletion
docs/FAQ
with
36 additions
and
1 deletion
docs/FAQ
+
36
−
1
View file @
a40b55d5
Updated:
Octo
ber 2
7
, 2000 (http://curl.haxx.se/docs/faq.shtml)
Updated:
Novem
ber 2
2
, 2000 (http://curl.haxx.se/docs/faq.shtml)
_ _ ____ _
___| | | | _ \| |
/ __| | | | |_) | |
...
...
@@ -48,6 +48,7 @@ FAQ
5. libcurl Issues
5.1 Is libcurl thread safe?
5.2 How can I receive all data into a large memory chunk?
6. License Issues
6.1 I have a GPL program, can I use the libcurl library?
...
...
@@ -402,6 +403,40 @@ FAQ
README file from those who have used libcurl in a threaded environment,
since I haven't and I get this question more and more frequently!
5.2 How can I receive all data into a large memory chunk?
You are in full control of the callback function that gets called every time
there is data received from the remote server. You can make that callback do
whatever you want. You do not have to write the receivied data to a file.
One solution to this problem could be to have a pointer to a struct that you
pass to the callback function. You set the pointer using the
curl_easy_setopt(CURLOPT_FILE) function. Then that pointer will be passed to
the callback instead of a FILE * to a file:
/* imaginary struct */
struct MemoryStruct {
char *memory;
size_t size;
};
/* imaginary callback function */
size_t
WriteMemoryCallback(void *ptr, size_t size, size_t nmemb, void *data)
{
register int realsize = size * nmemb;
struct MemoryStruct *mem = (struct MemoryStruct *)data;
mem->memory = (char *)realloc(mem->memory, mem->size + realsize + 1);
if (mem->memory) {
memcpy(&(mem->memory[mem->size]), ptr, realsize);
mem->size += realsize;
mem->memory[mem->size] = 0;
}
return realsize;
}
6. License Issues
Curl and libcurl are released under the MPL, the Mozilla Public License. To
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment