Skip to content

Commit

Permalink
Added function.
Browse files Browse the repository at this point in the history
  • Loading branch information
mmlacak committed Nov 22, 2023
1 parent 015c972 commit ae286ba
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 12 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ converted to UTC for easier comparison.
**Application** and **library versions** can be seen in an application, using `version` command. \
The latest versions are:

Application: 0.0.1.422:854+20231122.064103 <!--- readme-new-app-version-major-minor-feature-commit+meta~breaks-place-marker --> \
Library: 0.0.1.422:854+20231122.064103 <!--- readme-new-lib-version-major-minor-feature-commit+meta~breaks-place-marker -->
Application: 0.0.1.423:855+20231122.070013 <!--- readme-new-app-version-major-minor-feature-commit+meta~breaks-place-marker --> \
Library: 0.0.1.423:855+20231122.070013 <!--- readme-new-lib-version-major-minor-feature-commit+meta~breaks-place-marker -->

Versioning used is [Natural Versioning 1.2](https://croatian-chess.blogspot.com/p/natver.html),
with meta data containing the same format as the book version.
Expand Down
2 changes: 1 addition & 1 deletion ws/crochess/src/crochess.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include "crochess.h"


char const CROCHESS_VERSION[] = "0.0.1.422:854+20231122.064103"; // source-new-crochess-version-major-minor-feature-commit+meta~breaks-place-marker
char const CROCHESS_VERSION[] = "0.0.1.423:855+20231122.070013"; // source-new-crochess-version-major-minor-feature-commit+meta~breaks-place-marker

#ifdef __WITH_LINE_NOISE__
char const CROCHESS_HISTORY_FILE_NAME[] = "history_crochess.txt";
Expand Down
7 changes: 6 additions & 1 deletion ws/libcrochess/inc/cc_path.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,11 @@ bool cc_path_node_free_all( CcPathNode ** restrict path_node__f );
*/
size_t cc_path_node_count_alt( CcPathNode * restrict path_node );

// TODO :: DELETE after cc_path_find_shortest_route(), cc_path_find_longest_route() are done
//

//
// Linked list of nodes.
// Linked list of weak pointers to path node.

// /**
// Linked list of weak pointers to nodes, comprising one route. A route follows paths from starting field to destination.
Expand Down Expand Up @@ -223,6 +225,9 @@ size_t cc_path_node_count_alt( CcPathNode * restrict path_node );
// */
// size_t cc_path_weak_len( CcPathWeak * restrict path_weak );

//
// TODO :: DELETE after cc_path_find_shortest_route(), cc_path_find_longest_route() are done


//
// Auxilary functions.
Expand Down
30 changes: 24 additions & 6 deletions ws/libcrochess/src/cc_path.c
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ size_t cc_path_node_count_alt( CcPathNode * restrict path_node ) {


//
// Linked list of nodes.
// Linked list of weak pointers to path node.

typedef struct CcPathWeak {
CcPathNode * node__w;
Expand Down Expand Up @@ -200,9 +200,9 @@ static CcPathWeak * cc_path_weak_append( CcPathWeak ** restrict path_weak__iod,
if ( !*path_weak__iod ) {
*path_weak__iod = pw__t; // Ownership transfer.
} else {
CcPathWeak * pl = *path_weak__iod;
CC_FASTFORWARD( pl );
pl->next = pw__t; // Append + ownership transfer.
CcPathWeak * pw = *path_weak__iod;
CC_FASTFORWARD( pw );
pw->next = pw__t; // Append + ownership transfer.
}

return pw__t; // Weak pointer.
Expand All @@ -212,7 +212,6 @@ static bool cc_path_weak_free_all( CcPathWeak ** restrict path_weak__f ) {
if ( !path_weak__f ) return false;
if ( !*path_weak__f ) return true;

bool result = true;
CcPathWeak * pw = *path_weak__f;
CcPathWeak * tmp = NULL;

Expand All @@ -223,7 +222,7 @@ static bool cc_path_weak_free_all( CcPathWeak ** restrict path_weak__f ) {
}

*path_weak__f = NULL;
return result;
return true;
}

static size_t cc_path_weak_len( CcPathWeak * restrict path_weak ) {
Expand All @@ -240,6 +239,25 @@ static size_t cc_path_weak_len( CcPathWeak * restrict path_weak ) {
return len;
}

static CcPathWeak * cc_path_weak_initialize_route( CcPathNode * restrict path_node ) {
if ( !path_node ) return NULL;

CcPathNode * pn = path_node;
CcPathWeak * pw__a = NULL;

while ( pn ) {
CcPathWeak * pw__w = cc_path_weak_append( &pw__a, pn );
if ( !pw__w ) { // Append failed ...
cc_path_weak_free_all( &pw__a );
return NULL;
}

pn = pn->divergence;
}

return pw__a;
}


//
// Auxilary functions.
Expand Down
2 changes: 1 addition & 1 deletion ws/libcrochess/src/cc_version.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
*/


char const CC_LIB_VERSION[] = "0.0.1.422:854+20231122.064103"; // source-new-libcrochess-version-major-minor-feature-commit+meta~breaks-place-marker
char const CC_LIB_VERSION[] = "0.0.1.423:855+20231122.070013"; // source-new-libcrochess-version-major-minor-feature-commit+meta~breaks-place-marker
2 changes: 1 addition & 1 deletion ws/tests/src/tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
#include "tests.h"


char const CROCHESS_TESTS_VERSION[] = "0.0.1.422:854+20231122.064103"; // source-new-crochess-tests-version-major-minor-feature-commit+meta~breaks-place-marker
char const CROCHESS_TESTS_VERSION[] = "0.0.1.423:855+20231122.070013"; // source-new-crochess-tests-version-major-minor-feature-commit+meta~breaks-place-marker

#ifdef __WITH_LINE_NOISE__
char const CROCHESS_TESTS_HISTORY_FILE_NAME[] = "history_tests.txt";
Expand Down

0 comments on commit ae286ba

Please sign in to comment.