Thread: Non alligned pointer being freed

  1. #1
    Registered User
    Join Date
    Oct 2010
    Posts
    8

    Non alligned pointer being freed

    The following code generates error: non alligned pointer being freed.
    What can I do to fix it?

    Code:
    Experto::~Experto(){
    	for(int i = 0; i < 7; ++i){
    		delete this->tableroIndices[i];
    		this->tableroIndices[i] = 0;
    	}
    	delete this->tableroIndices;	
    	delete this->listaEstados;
    	delete this->solucion;
    	this->tableroIndices = 0;
    	listaEstados = 0;
    	solucion = 0;
    }

    Here's the tableroIndice's declaration and creation process....

    Code:
    char ** tableroIndices;
    Code:
    void Experto::inicializarTableroIndices(){
    	this->tableroIndices = new char * [7];
    	char indiceTablero = '0';
    	for(int i = 0; i < 7; ++i){
    		tableroIndices[i] = new char[7];
    		for(int j = 0; j < 7; ++j){
    			if((i < 2 || i > 4) && (j < 2 || j > 4)){
    				this->tableroIndices[i][j] = '_';
    			}else{
    				this->tableroIndices[i][j] = indiceTablero;
    				indiceTablero += 1;
    				if(indiceTablero == ':'){
    					indiceTablero += 7;
    				}
    			}
    		}
    	}
    }
    Thanks for helping!

  2. #2
    Registered User
    Join Date
    Oct 2010
    Posts
    107
    Could you please tell us the line number? In the future, please put C++ code in the other forum.
    Last edited by QuadraticFighte; 10-20-2010 at 08:56 PM.

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    Moved
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    And how do you initialise these?
    delete this->listaEstados;
    delete this->solucion;
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compiling C in Visual Studio 2005
    By emanresu in forum C Programming
    Replies: 3
    Last Post: 11-16-2009, 04:25 AM
  2. Replies: 1
    Last Post: 03-24-2008, 10:16 AM
  3. Replies: 0
    Last Post: 03-20-2008, 07:59 AM
  4. Direct3D problem
    By cboard_member in forum Game Programming
    Replies: 10
    Last Post: 04-09-2006, 03:36 AM
  5. Struct *** initialization
    By Saravanan in forum C Programming
    Replies: 20
    Last Post: 10-09-2003, 12:04 PM