Skip to main content
GameDev.net gamedev.net
🔒 Locked

memory management

Started by k2uza Jan 18, 2001 at 10:50 PM 1 replies 400+ views
Original Post
k2uza
k2uza
I am attempting to make a general memory module that allocates initially a large block and than generates and manages that block through out the game procedures. BYTE * memoryPool = malloc (10000000); BYTE * temp = getPointerFromGeneralMemPool (1000); /*get pointer that is size 1000 within memoryPool */ now, in getPointerFromGeneralMemPool (xxx), how do i force the pointer that will be returned not to more than the defined size. Cuz, if a malloc a pointer to 100 bytes and go beyond that you get crashes (which, is oddly what I want). But, since I have already allocated a large block initially, and i just return a pointer within that block it wont crash. I dont want procedures to be able to corrupt the memoryPool by having individual pointers within that large block overlap accidently. I hope that explains its. Thanks. K2
Anonypous Moster
Anonypous Moster
I don''t think you can do that without using the memory management stuff in the CPU, which is probably not available in user (or whatever the intel equivalent is) mode.

You could put little buffers between each allocated memory block (which could also double as alignment buffers). Fill these buffers with known data, then periodically check them. If they change then you have overwritten data.
Gee Brain, what we gonna do tonight?

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.