Re: Unusual memory allocation problem

D. Schwingel (ds@conex.com.br)
Mon, 14 Sep 1998 22:21:47 -0300


Chetan Kumar wrote:
>
[...]
> Any this buggy !?!
[...]
> #include<stdio.h>
>
> main()
> {
> char *c[400];
> int i;
> for(i=0;i<400;i++)
> {
> if((c[i] = malloc(1024*2000)) == NULL)
> perror("Could not allocate 2MB");
> else
> printf("\nSuccess %d th time",i);
> }
> }

When I was a programmer I was used to include stdlib.h to use *lloc
functions, but not sure if this is the answer.

$man malloc
NAME
calloc, malloc, free, realloc - Allocate and free dynamic
memory

SYNOPSIS
#include <stdlib.h>

void *calloc(size_t nmemb, size_t size);
void *malloc(size_t size);
void free(void *ptr);
void *realloc(void *ptr, size_t size);

But might be.

Dino
ds@conex.net

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/