This repository was archived by the owner on Jul 12, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmemoryAllocation.h
62 lines (41 loc) · 1.77 KB
/
memoryAllocation.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#ifndef FINAL_MEMORYALLOCATION_H
#define FINAL_MEMORYALLOCATION_H
#include "gameParams.h"
#include "errorMessages.h"
/* 1. gameParams (the whole game): */
/* Allocates memory for a new gameParams struct
* Initializes its fields to default values
* Called once by the play() function in the beginning of the program */
gameParams *initSudokuGame();
/* Pre:
* 1. Memory for game already allocated
* 2. Memory for game internal fields *not* allocated
* Post: Initializes game fields to a (m*n)*(m*n) sudoku game */
void initializeSudokuGameFields(gameParams *game, int m, int n);
/* Frees all memory allocated to game, including game itself
* (This is the complementary free function of initSudokuGame() */
int freeSudokuGame(gameParams *game);
/* Frees memory allocated to game fields, and initializes its fields */
void cleanSudokuGame(gameParams *game);
/* 2. Board (cell ***) and (int **) */
/* Allocates memory for cell matrix mat with NxN values */
cell ***allocateCellMatrix(int N);
/* Frees all memory allocated to the given board
* (This is the complementary free function of allocateCellMatrix */
void freeCellMatrix(cell ***mat, int N);
/* "Constructor" - creates a cell with the passed value. By default new cells are valid and no fixed */
cell *createCell(int value);
/* Allocates memory for int matrix
* with size N*N */
int **allocateIntMatrix(int N);
/* Frees memory allocated for matrix mat of size n*/
void freeIntMatrix(int **mat, int n);
/* 3. List of moves: */
/* frees all the userMoveNode
* starting from moveToFree to the end */
void freeAllUserMoveNodes(userMoveNode *moveToFree);
/* frees all the freeCellChangeRecNode
* starting from change to the end */
void freeCellChangeRecNode(cellChangeRecNode *changeToFree);
listOfMoves *allocateMoveList();
#endif