www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/03/03/08:18:08

From: ps13 AT gauss DOT ma DOT ic DOT ac DOT uk (Mr P. Steele)
Newsgroups: comp.os.msdos.djgpp
Subject: malloc help
Date: 3 Mar 1997 11:37:27 GMT
Organization: Imperial College, London, UK
Message-ID: <5fed5n$qtp@oban.cc.ic.ac.uk>
NNTP-Posting-Host: jacobi.ma.ic.ac.uk
Lines: 27
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

I have a struct

pcx_picture_type
{
...
...
...
char * buffer
}pcx_picture

and I use it this function to allocate memory for for the screen buffer

pcx_int(pcx_picture *image)
{

if(!(image->buffer = (char *)malloc(SCREEN_WIDTH * SCREEN_HEIGHT + 1)));

  printf("Could not allocate screen buffer.");

}

I have a 16 M ram 80 meg vitual ram so I guess there is plenty of memory, but
the program keeps stopping at this point saying it could not allocate memory.
This progam works fine in borland c . I was wondering if any of my syntax was
wrong for it to work in DJGPP.

**p DOT steele AT ic DOT ac DOT uk**

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019