Initialize array for new solution to -1
This commit is contained in:
parent
3e34253092
commit
56df02a288
@ -40,6 +40,10 @@ void initCircBuf()
|
|||||||
|
|
||||||
void getSolution(sem_t sUsedSpace, sem_t sFreeSpace, int *solution)
|
void getSolution(sem_t sUsedSpace, sem_t sFreeSpace, int *solution)
|
||||||
{
|
{
|
||||||
|
for (int i = 0; i < MAX_ITEMS; i++) {
|
||||||
|
solution[i] = -1;
|
||||||
|
}
|
||||||
|
|
||||||
if (shared->head == -1) {
|
if (shared->head == -1) {
|
||||||
sem_wait(&sUsedSpace);
|
sem_wait(&sUsedSpace);
|
||||||
shared->head = (shared->head + 1) % MAX_ITEMS;
|
shared->head = (shared->head + 1) % MAX_ITEMS;
|
||||||
@ -129,7 +133,7 @@ int main(int argc, char *argv[])
|
|||||||
initCircBuf();
|
initCircBuf();
|
||||||
|
|
||||||
while (quit == 0) {
|
while (quit == 0) {
|
||||||
int solution[MAX_ITEMS] = {-1};
|
int solution[MAX_ITEMS];
|
||||||
getSolution(*sUsedSpace, *sFreeSpace, solution);
|
getSolution(*sUsedSpace, *sFreeSpace, solution);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user