Skip to content

Commit 48f4178

Browse files
committed
Reformated the project.
1 parent 16fa68a commit 48f4178

File tree

27 files changed

+122
-190
lines changed

27 files changed

+122
-190
lines changed

DataStructure/Deque/Sources/DLinkedListDeque.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ void destroyDLDeque(void *deque) {
360360

361361
}
362362

363-
destroyDoublyLinkedList( ((DLDeque *) deque)->linkedList );
363+
destroyDoublyLinkedList(((DLDeque *) deque)->linkedList);
364364
free(deque);
365365

366366
}

DataStructure/Deque/Sources/Deque.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,6 @@ void destroyDeque(void *deque) {
462462
}
463463

464464
clearDeque(deque);
465-
free( ((Deque *) deque)->arr );
465+
free(((Deque *) deque)->arr);
466466
free(deque);
467467
}

DataStructure/Graphs/Sources/DirectedGraph.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,7 @@ void destroyDirGraph(void *graph) {
591591

592592
}
593593

594-
destroyHashMap( ((DirectedGraph *)graph)->nodes );
594+
destroyHashMap(((DirectedGraph *) graph)->nodes);
595595
free(graph);
596596

597597
}

DataStructure/Graphs/Sources/UndirectedGraph.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -851,7 +851,7 @@ void destroyUDGraph(void *graph) {
851851

852852
}
853853

854-
destroyHashMap( ((UndirectedGraph *)graph)->nodes );
854+
destroyHashMap(((UndirectedGraph *) graph)->nodes);
855855
free(graph);
856856

857857
}

DataStructure/Lists/Sources/ArrayList.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ arrayListInitialization(int initialLength, void (*freeFun)(void *), int (*compar
1818
if (freeFun == NULL) {
1919
#ifdef C_DATASTRUCTURES_ERRORSTESTSTRUCT_H
2020
ERROR_TEST->errorCode = INVALID_ARG;
21-
return NULL;
21+
return NULL;
2222
#else
2323
fprintf(stderr, INVALID_ARG_MESSAGE, "free function", "array list data structure");
2424
exit(INVALID_ARG);
@@ -841,7 +841,7 @@ void destroyArrayList(void *list) {
841841
}
842842

843843
clearArrayList(list);
844-
free( ((ArrayList *) list)->arr );
844+
free(((ArrayList *) list)->arr);
845845
free(list);
846846

847847
}

DataStructure/Lists/Sources/Vector.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ void vectorAdd(Vector *list, void *item) {
7979
if (list == NULL) {
8080
#ifdef C_DATASTRUCTURES_ERRORSTESTSTRUCT_H
8181
ERROR_TEST->errorCode = NULL_POINTER;
82-
return;
82+
return;
8383
#else
8484
fprintf(stderr, NULL_POINTER_MESSAGE, "vector", "vector data structure");
8585
exit(NULL_POINTER);
@@ -88,7 +88,7 @@ void vectorAdd(Vector *list, void *item) {
8888
} else if (item == NULL) {
8989
#ifdef C_DATASTRUCTURES_ERRORSTESTSTRUCT_H
9090
ERROR_TEST->errorCode = INVALID_ARG;
91-
return;
91+
return;
9292
#else
9393
fprintf(stderr, INVALID_ARG_MESSAGE, "item pointer", "vector data structure");
9494
exit(INVALID_ARG);
@@ -103,7 +103,7 @@ void vectorAdd(Vector *list, void *item) {
103103
if (list->arr == NULL) {
104104
#ifdef C_DATASTRUCTURES_ERRORSTESTSTRUCT_H
105105
ERROR_TEST->errorCode = FAILED_REALLOCATION;
106-
return;
106+
return;
107107
#else
108108
fprintf(stderr, FAILED_REALLOCATION_MESSAGE, "items memory", "vector data structure");
109109
exit(FAILED_REALLOCATION);
@@ -462,7 +462,7 @@ int vectorGetIndex(Vector *list, void *item) {
462462
} else if (list->comparator == NULL) {
463463
#ifdef C_DATASTRUCTURES_ERRORSTESTSTRUCT_H
464464
ERROR_TEST->errorCode = NULL_POINTER;
465-
return -1;
465+
return -1;
466466
#else
467467
fprintf(stderr, NULL_POINTER_MESSAGE, "comparator function", "vector data structure");
468468
exit(NULL_POINTER);
@@ -841,7 +841,7 @@ void destroyVector(void *list) {
841841
}
842842

843843
clearVector(list);
844-
free( ((Vector *) list)->arr );
844+
free(((Vector *) list)->arr);
845845
free(list);
846846

847847
}

DataStructure/Matrices/Sources/Matrix.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -1007,9 +1007,9 @@ void destroyMatrix(void *matrix) {
10071007
clearMatrix(matrix);
10081008

10091009
for (int i = 0; i < ((Matrix *) matrix)->rowsNum; i++)
1010-
free( ((Matrix *) matrix)->rows[i] );
1010+
free(((Matrix *) matrix)->rows[i]);
10111011

1012-
free( ((Matrix *) matrix)->rows );
1012+
free(((Matrix *) matrix)->rows);
10131013
free(matrix);
10141014

10151015
}

DataStructure/Pairs/Headers/Pair.h

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ typedef struct Pair {
2424
void *sElem;
2525

2626
void (*fFreeFn)(void *);
27+
2728
void (*sFreeFn)(void *);
2829

2930
} Pair;

DataStructure/Pairs/Sources/Pair.c

-31
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@
33
#include "../../../Unit Test/CuTest/CuTest.h"
44

55

6-
7-
8-
9-
106
/** This function will allocate a new pair then it will return it's pointer.
117
*
128
* @param fElem the first element pointer
@@ -68,11 +64,6 @@ Pair *pairInitialization(void *fElem, void *sElem, void (*fFreeFn)(void *), void
6864
}
6965

7066

71-
72-
73-
74-
75-
7667
/** This function will return the first element in the pair.
7768
*
7869
* @param pair the pair pointer
@@ -96,9 +87,6 @@ void *pairGetFElem(Pair *pair) {
9687
}
9788

9889

99-
100-
101-
10290
/** This function will return the second element in the pair.
10391
*
10492
* @param pair the pair pointer
@@ -122,9 +110,6 @@ void *pairGetSElem(Pair *pair) {
122110
}
123111

124112

125-
126-
127-
128113
/** This function will set the first element in the pair.
129114
*
130115
* Note: this function will free the old element
@@ -160,9 +145,6 @@ void pairSetFElem(Pair *pair, void *newElem) {
160145
}
161146

162147

163-
164-
165-
166148
/** This function will set the second element in the pair.
167149
*
168150
* Note: this function will free the old element
@@ -198,10 +180,6 @@ void pairSetSElem(Pair *pair, void *newElem) {
198180
}
199181

200182

201-
202-
203-
204-
205183
/** This function will set the first element in the pair,
206184
* without freeing the old element.
207185
*
@@ -234,9 +212,6 @@ void pairSetFElemWtoFr(Pair *pair, void *newElem) {
234212
}
235213

236214

237-
238-
239-
240215
/** This function will set the second element in the pair,
241216
* without freeing the old element.
242217
*
@@ -269,10 +244,6 @@ void pairSetSElemWtoFr(Pair *pair, void *newElem) {
269244
}
270245

271246

272-
273-
274-
275-
276247
/** This function will swap the pair elements.
277248
*
278249
* @param pair the pair pointer
@@ -301,8 +272,6 @@ void pairSwapElements(Pair *pair) {
301272
}
302273

303274

304-
305-
306275
/** This function will destroy and free the pair and its elements.
307276
*
308277
* @param pair the pair pointer

DataStructure/Queues/Headers/HPriorityQueue.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ typedef struct HPriorityQueue {
1212

1313
struct BinaryHeap *heap;
1414

15-
}HPriorityQueue;
15+
} HPriorityQueue;
1616

1717

1818
HPriorityQueue *hPriorityQueueInitialization(void (*freeFn)(void *), int (*cmp)(const void *, const void *));

DataStructure/Queues/Sources/HPriorityQueue.c

+1-24
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
#include "../../Trees/Headers/BinaryHeap.h"
55

66

7-
8-
97
/** This function will return the first child index,
108
* of the passed parent index.
119
*
@@ -50,7 +48,6 @@ void hpQueueSwap(void **arr, int fIndex, int sIndex) {
5048
}
5149

5250

53-
5451
/** This function will heap down the value in the passed index until it be in the right place.
5552
*
5653
* @param arr the array pointer
@@ -91,7 +88,6 @@ void hpQueueHeapDown(void **arr, int currentIndex, int length, int (*cmp)(const
9188
}
9289

9390

94-
9591
/** This function will allocate a new heap priority queue then it will return its pointer.
9692
*
9793
* @param freeFn the free function pointer, that will be called to free the queue items
@@ -132,9 +128,6 @@ HPriorityQueue *hPriorityQueueInitialization(void (*freeFn)(void *), int (*cmp)(
132128
}
133129

134130

135-
136-
137-
138131
/** This function will insert the passed item in the queue.
139132
*
140133
* @param queue the queue pointer
@@ -167,8 +160,6 @@ void hpQueueEnqueue(HPriorityQueue *queue, void *item) {
167160
}
168161

169162

170-
171-
172163
/** This function will insert all the passed array items in the queue.
173164
*
174165
* @param queue the queue pointer
@@ -201,8 +192,6 @@ void hpQueueEnqueueAll(HPriorityQueue *queue, void *items, int length) {
201192
}
202193

203194

204-
205-
206195
/** This function will remove the first item from the queue,
207196
* then it will return it.
208197
*
@@ -237,8 +226,6 @@ void *hpQueueDequeue(HPriorityQueue *queue) {
237226
}
238227

239228

240-
241-
242229
/** This function will return the first item in the queue without removing it from the queue.
243230
*
244231
* @param queue the queue pointer
@@ -272,8 +259,6 @@ void *hpQueuePeek(HPriorityQueue *queue) {
272259
}
273260

274261

275-
276-
277262
/** This function will return the number of items in the queue.
278263
*
279264
* @param queue the queue pointer
@@ -298,8 +283,6 @@ int hpQueueGetLength(HPriorityQueue *queue) {
298283
}
299284

300285

301-
302-
303286
/** This function will check if the queue is empty or not,
304287
* and if it was the function will return one (1),
305288
* other wise it will return zero (0).
@@ -326,8 +309,6 @@ int hpQueueIsEmpty(HPriorityQueue *queue) {
326309
}
327310

328311

329-
330-
331312
/** This function will return a double void array that contains the queue items.
332313
*
333314
* Note: the array will be sorted.
@@ -349,7 +330,7 @@ void **hpQueueToArray(HPriorityQueue *queue) {
349330

350331
}
351332

352-
void **arr = binaryHeapToArray(queue->heap);
333+
void **arr = binaryHeapToArray(queue->heap);
353334

354335
int length = hpQueueGetLength(queue);
355336

@@ -366,8 +347,6 @@ void **hpQueueToArray(HPriorityQueue *queue) {
366347
}
367348

368349

369-
370-
371350
/** This function will clear the queue and free all it's items,
372351
* without freeing the queue itself.
373352
*
@@ -392,8 +371,6 @@ void clearHPQueue(HPriorityQueue *queue) {
392371
}
393372

394373

395-
396-
397374
/** This function will destroy and free the queue and it's items.
398375
*
399376
* @param queue the queue pointer

DataStructure/Queues/Sources/LinkedListQueue.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ void destroyLLQueue(void *queue) {
302302

303303
}
304304

305-
destroyLinkedList( ((LinkedListQueue *)queue)->linkedList);
305+
destroyLinkedList(((LinkedListQueue *) queue)->linkedList);
306306
free(queue);
307307

308308
}

DataStructure/Queues/Sources/PriorityQueue.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ void pQueueEnqueue(PriorityQueue *queue, void *item) {
117117
if (!memcpy(tempArr, queue->arr + queue->fPointer, sizeof(void *) * (queue->count - queue->fPointer))) {
118118
#ifdef C_DATASTRUCTURES_ERRORSTESTSTRUCT_H
119119
ERROR_TEST->errorCode = FAILED_COPY;
120-
return;
120+
return;
121121
#else
122122
fprintf(stderr, FAILED_COPY_MESSAGE, "new queue array", "priority queue data structure");
123123
exit(FAILED_COPY);
@@ -392,7 +392,7 @@ void destroyPQueue(void *queue) {
392392
}
393393

394394
clearPQueue(queue);
395-
free( ((PriorityQueue *) queue)->arr );
395+
free(((PriorityQueue *) queue)->arr);
396396
free(queue);
397397

398398
}

DataStructure/Queues/Sources/Queue.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ void queueEnqueue(Queue *arrayQueue, void *data) {
9191
if (tempArr == NULL) {
9292
#ifdef C_DATASTRUCTURES_ERRORSTESTSTRUCT_H
9393
ERROR_TEST->errorCode = FAILED_ALLOCATION;
94-
return;
94+
return;
9595
#else
9696
fprintf(stderr, FAILED_ALLOCATION_MESSAGE, "items memory", "queue data structure");
9797
exit(FAILED_ALLOCATION);
@@ -165,7 +165,7 @@ void destroyQueue(void *arrayQueue) {
165165

166166
clearQueue(arrayQueue);
167167

168-
free( ((Queue *) arrayQueue)->memory );
168+
free(((Queue *) arrayQueue)->memory);
169169
free(arrayQueue);
170170

171171
}

DataStructure/Stacks/Sources/DLinkedListStack.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ void destroyDLStack(void *stack) {
412412

413413
}
414414

415-
destroyDoublyLinkedList( ((DLinkedListStack *) stack)->linkedList );
415+
destroyDoublyLinkedList(((DLinkedListStack *) stack)->linkedList);
416416
free(stack);
417417

418418
}

0 commit comments

Comments
 (0)