~ubuntu-branches/ubuntu/natty/curl/natty

« back to all changes in this revision

Viewing changes to docs/examples/getinmemory.c

  • Committer: Bazaar Package Importer
  • Author(s): Michael Vogt
  • Date: 2009-04-29 11:10:29 UTC
  • mfrom: (3.2.3 sid)
  • Revision ID: james.westby@ubuntu.com-20090429111029-2j5eiyokfw2bw049
Tags: 7.19.4-1ubuntu1
* Merge from debian unstable, remaining changes:
  - Drop build dependencies: stunnel, libdb4.6-dev, libssh2-1-dev
  - Add build-dependency on openssh-server
  - Drop libssh2-1-dev from libcurl4-openssl-dev's Depends.
  - Call automake-1.9 with --add-missing --copy --force
* drop debian/patches/security_CVE-2009-0037.patch 
  - this patch is part of 7.19.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
 *                            | (__| |_| |  _ <| |___
6
6
 *                             \___|\___/|_| \_\_____|
7
7
 *
8
 
 * $Id: getinmemory.c,v 1.12 2007-11-07 04:53:37 danf Exp $
 
8
 * $Id: getinmemory.c,v 1.13 2008-09-06 04:28:45 yangtse Exp $
9
9
 *
10
10
 * Example source code to show how the callback function can be used to
11
11
 * download data into a chunk of memory instead of storing it in a file.
26
26
  size_t size;
27
27
};
28
28
 
 
29
static void *myrealloc(void *ptr, size_t size);
 
30
 
29
31
static void *myrealloc(void *ptr, size_t size)
30
32
{
31
33
  /* There might be a realloc() out there that doesn't like reallocing
42
44
  size_t realsize = size * nmemb;
43
45
  struct MemoryStruct *mem = (struct MemoryStruct *)data;
44
46
 
45
 
  mem->memory = (char *)myrealloc(mem->memory, mem->size + realsize + 1);
 
47
  mem->memory = myrealloc(mem->memory, mem->size + realsize + 1);
46
48
  if (mem->memory) {
47
49
    memcpy(&(mem->memory[mem->size]), ptr, realsize);
48
50
    mem->size += realsize;