Thread: Valgrind Move-Allocation

  1. #1
    Registered User
    Join Date
    Feb 2019
    Posts
    67

    Valgrind Move-Allocation

    Hey,

    given that;

    Code:
     
    for(int k = 0; k < 2; k++){               
          const char *move = create_move_string_by_fields(pmove_data->moves[i][0],
           (pmove_data->moves[i][0]+pmove_data->moves[i][k])/2, 0);
            BOARD_STATE bstate = make_move_with_copy(pboard_state, move);
            MOVE_DATA new_move_data = return_all_moves(&bstate, 0);
            if(can_king_be_killed(&bstate, &new_move_data)){
                  memset(pmove_data->moves[i],0,CHARS_TO_EXPRESS_MOVE);
                   continue_inner_check = 0;
                    break;
              }
               free(move);
                delete_MOVE_DATA(&new_move_data);
                }
    Valgrind cries:

    ==13333== 3 bytes in 1 blocks are definitely lost in loss record 10 of 31
    ==13333== at 0x4C2FB0F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
    ==13333== by 0x10BB8B: create_move_string_by_fields (odinutilities.c:56)
    ==13333== by 0x10A622: filter_all_legal_moves (board.c:574)
    ==13333== by 0x109A02: return_all_legal_moves (board.c:317)
    ==13333== by 0x10AF2E: minimax (calculation.c:70)
    ==13333== by 0x10B414: main (main.c:43)
    ==13333==

    I just do not know why...

    Code:
    char* create_move_string_by_fields(char from, char to, char promotion_piece) {
        char* move = malloc(CHARS_TO_EXPRESS_MOVE);
        move[0] = from;
        move[1] = to;
        move[2] = promotion_piece;
        return move;
    }

    EDIT: SOLVED
    Last edited by SuchtyTV; 08-10-2019 at 03:16 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 3
    Last Post: 01-27-2019, 07:56 AM
  2. Replies: 4
    Last Post: 11-01-2016, 07:13 AM
  3. Replies: 8
    Last Post: 08-03-2014, 10:57 PM
  4. Replies: 5
    Last Post: 01-15-2011, 12:31 PM
  5. Memory Allocation Error - /w Valgrind Output
    By Ggregagnew in forum C Programming
    Replies: 5
    Last Post: 12-02-2010, 04:02 PM

Tags for this Thread