Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

sckoobs

Malloc Prob

This topic is 6335 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Righty, I am trying to load a bitmap and I want to allocate it some memory for the actual bitmap bits.
  

    GLubyte          *bits;

    bits = malloc(bitsize);
	if (bits == NULL)
    {
        // Couldn't allocate memory - return NULL

        free(*info);
        fclose(fp);
        return (NULL);
    }

  
The error I'm getting in (VC++ 6.0) is: "error C2440: '=' : cannot convert from 'void *' to 'unsigned char *' Conversion from 'void*' to pointer to non-'void' requires an explicit cast" Now the declaration of malloc is void malloc(...) but in the example in the help file it shows malloc being used for allocating memory to a pointer to a character i.e:
  

   char *string;

   /* Allocate space for a path name */
   string = malloc( _MAX_PATH );
   if( string == NULL )
      printf( "Insufficient memory available\n" );

  
Any ideas - they will be much appreciated! Max Edited by - sckoobs on March 17, 2001 8:43:12 AM

Share this post


Link to post
Share on other sites
Advertisement
remember that even though your program looks like a C program, you are still compiling it with a C++ compiler, and C++ is more picky about types than C

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!