From f418404bf395f5ad5b5dccaf9547c3e016a8dad6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonard=20Ikl=C3=A9?= Date: Wed, 7 Feb 2024 20:06:05 +0100 Subject: [PATCH] better documentation of the return value in the normalize function #45 --- docs/reference/cwk_path_normalize.md | 2 +- include/cwalk.h | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/docs/reference/cwk_path_normalize.md b/docs/reference/cwk_path_normalize.md index 03ded2c..8ec28b4 100644 --- a/docs/reference/cwk_path_normalize.md +++ b/docs/reference/cwk_path_normalize.md @@ -11,7 +11,7 @@ Creates a normalized version of the path. size_t cwk_path_normalize(const char *path, char *buffer, size_t buffer_size); ``` -This function creates a normalized version of the path within the specified buffer. This function will not write out more than the specified buffer can contain. However, the generated string is always null-terminated - even if not the whole path is written out. The function returns the total number of characters the complete buffer would have, even if it was not written out completely. The path may be the same memory address as the buffer. +This function creates a normalized version of the path within the specified buffer. This function will not write out more than the specified buffer can contain. However, the generated string is always null-terminated - even if not the whole path is written out. The returned value is the amount of characters which the resulting path would take if it was not truncated (excluding the null-terminating character). The path may be the same memory address as the buffer. The following will be true for the normalized path: * "../" will be resolved. diff --git a/include/cwalk.h b/include/cwalk.h index bfb5ff9..b4b1536 100644 --- a/include/cwalk.h +++ b/include/cwalk.h @@ -321,9 +321,10 @@ CWK_PUBLIC size_t cwk_path_change_extension(const char *path, * This function creates a normalized version of the path within the specified * buffer. This function will not write out more than the specified buffer can * contain. However, the generated string is always null-terminated - even if - * not the whole path is written out. The function returns the total number of - * characters the complete buffer would have, even if it was not written out - * completely. The path may be the same memory address as the buffer. + * not the whole path is written out. The returned value is the amount of + * characters which the resulting path would take if it was not truncated + * (excluding the null-terminating character). The path may be the same memory + * address as the buffer. * * The following will be true for the normalized path: * 1) "../" will be resolved.