Is there a function that will take a memory address and see if it is in use? I need to know so that a function I'm writing can tell if a "long" is a number, or a location of a string.
Is there a function that will take a memory address and see if it is in use? I need to know so that a function I'm writing can tell if a "long" is a number, or a location of a string.
01011001 01101111 01110101 00100000 01110100 01101111 01101111 1101011 00100000 01110100 01101000 01101001 01110011 00100000 01101101 01110101 01100011 01101000 00100000 01110100 01101000 01101101 01100101 00100000 01110100 01101111 00100000 01110010 01100101 01100001 01100100 00100000 01011001 01101000 01101001 01110011 00111111 00100000 01000100 01100001 01101101 01101110 00100001 00000000
alloc is very implementation specific, so in short - the answer is no. Now you could hack your alloc functions to see how they are implemented on your system and then use that to find a solution to your problem, but it wouldn't be easy.
Now the fact that you are asking this question in the first place means that you have a design problem somewhere in your program. When malloc is called, you are the one which specifies how much memory to set aside, therefore if you need to know this size in the future - come up wich a mechanism of storing the memory size somewhere. It could be something as simple as:
Code:typedef struct _memloc { unsigned char* pmem; size_t memsize; } memloc, *pmemloc;
It's not my design problem, it's a problem in problem NerveBreak (http://nervebreak.sf.net/). I'm just trying to find a way around it.
01011001 01101111 01110101 00100000 01110100 01101111 01101111 1101011 00100000 01110100 01101000 01101001 01110011 00100000 01101101 01110101 01100011 01101000 00100000 01110100 01101000 01101101 01100101 00100000 01110100 01101111 00100000 01110010 01100101 01100001 01100100 00100000 01011001 01101000 01101001 01110011 00111111 00100000 01000100 01100001 01101101 01101110 00100001 00000000
Or why not implement a type variable so instead of guessing you can tell for sure?
If you understand what you're doing, you're not learning anything.
Try reading it and if you seg fault then you know you aren't allowed to use it
good idea: I'll try to see if I can implement that in NerveBreak.Originally Posted by itsme86
01011001 01101111 01110101 00100000 01110100 01101111 01101111 1101011 00100000 01110100 01101000 01101001 01110011 00100000 01101101 01110101 01100011 01101000 00100000 01110100 01101000 01101101 01100101 00100000 01110100 01101111 00100000 01110010 01100101 01100001 01100100 00100000 01011001 01101000 01101001 01110011 00111111 00100000 01000100 01100001 01101101 01101110 00100001 00000000
of course reading invalid memory doesn't always result in a seg fault either
Nervebreak appears to be opensource. It would be far easier to fix the problem there, than doing some hack in your own code.
That's worse than myOriginally Posted by Thantos
advice!Code:#define JLKJWERSDFDF std::cout