Welcome to mirror list, hosted at ThFree Co, Russian Federation.

memory.c « libgloss.all « testsuite « libgloss - cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 6e0422d3d2c5b9ce857c09027174eaa3625a8146 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/* WinBond bug report

   malloc() returns 0x0.

   test the memory calls. These test sbrk(), which is part of glue.c
   for most architectures.
 */

#include <stdio.h>
#define BUFSIZE 80

main()
{
  char *buf;
  char *tmp;
  char *result;

  /* see if we can get some memory */
  buf = (char *)malloc(BUFSIZE);
  if (buf != 0x0) {
    pass ("malloc");
  } else {
    fail ("malloc");
  }

  /* see if we can realloc it */
  tmp = buf;
  result = (char *)realloc (buf, BUFSIZE+100);
   if ((buf != 0x0) && (result != 0x0)) {
    pass ("realloc");
  } else {
    fail ("realloc");
  }
    
  /* see if we can free it up. FIXME: how to test free ?*/
  free (buf);
  fflush (stdout);
}