Looking at the code that I slapped together, does "clear()" from the map function leave a hole in memory? If so, how should I do I fix this?
Code:
#include <stdlib.h>
#include <map>
struct FOO {
char *A;
char *B;
char *C;
FOO &set_info( char *ptrA, char *ptrB, char *ptrC ) {
A = ptrA;
B = ptrB;
C = ptrC;
return *this;
}
};
typedef map<char *, FOO> MAP_TD_FOO;
int main ( void ) {
MAP_TD_FOO msi;
MAP_TD_FOO::iterator itor;
FOO foo;
char *a, *b, *c;
a = new char;
b = new char;
c = new char;
a = (char *)"Just";
b = (char *)"another";
c = (char *)"test";
msi[ a ] = foo.set_info( a, b, c );
char *key;
itor = msi.begin();
while( itor != msi.end() ){
key = (*itor).first;
foo = (*itor).second;
printf( "%s %s %s\n", foo.A, foo.B, foo.C );
itor++;
}
msi.clear(); // <------------Does clear leave a hole in memory?
exit ( 1 );
}
Thanks to any and all that respond.
DeadPoet