Skip to content

Commit 58e11f2

Browse files
committed
gpujpeg_image_save_to_file: (const char *) fname
gpujpeg_image_save_to_file() - take (const char *) for filename instead of (char *). This reverts back the change in the function prototype by the commit de0f3a8 (2025-02-28). The (const char *) still can be modified as per the change but it is rather a special case that is docuemented in doxy. refer to GH-98
1 parent 4301965 commit 58e11f2

File tree

5 files changed

+14
-6
lines changed

5 files changed

+14
-6
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
cmake_minimum_required(VERSION 3.10.0 FATAL_ERROR)
22
# change version also in configure.ac
3-
project(gpujpeg VERSION 0.27.0 LANGUAGES C CUDA)
3+
project(gpujpeg VERSION 0.27.1 LANGUAGES C CUDA)
44

55
# options
66
set(BUILD_OPENGL OFF CACHE STRING "Build with OpenGL support, options are: AUTO ON OFF")

NEWS.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
2025-05-14 - 0.27.1
2+
----------
3+
4+
- gpujpeg_image_save_to_file() - take (const char *) for filename instead
5+
of (char *)
6+
17
2025-05-12 - 0.27.0
28
----------
39

configure.ac

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
AC_PREREQ([2.65])
22
# change version also in CMakeLists.txt
3-
AC_INIT([libgpujpeg],[0.27.0],[https://github.com/CESNET/GPUJPEG/issues],[libgpujpeg],[https://github.com/CESNET/GPUJPEG])
3+
AC_INIT([libgpujpeg],[0.27.1],[https://github.com/CESNET/GPUJPEG/issues],[libgpujpeg],[https://github.com/CESNET/GPUJPEG])
44
AC_CONFIG_MACRO_DIR([m4])
55
AC_CONFIG_SRCDIR([src/main.c])
66
AC_CONFIG_AUX_DIR([.])

libgpujpeg/gpujpeg_common.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,8 @@ gpujpeg_image_load_from_file(const char* filename, uint8_t** image, size_t* imag
414414
* Use the extension "XXX" (eg. "image.XXX") to automatically select the
415415
* extension according to param_image. PNM is used for grayscale or RGB, PAM for
416416
* RGBA, Y4M ottherwise. "XXX" placeholder in filename is replaced with used
417-
* extension.
417+
* extension. It is user responsibility to ensure that @ref filename is writable
418+
* in this case.
418419
*
419420
* @param filaname Image filename
420421
* @param image Image data buffer
@@ -423,7 +424,7 @@ gpujpeg_image_load_from_file(const char* filename, uint8_t** image, size_t* imag
423424
* @return 0 if succeeds, otherwise nonzero
424425
*/
425426
GPUJPEG_API int
426-
gpujpeg_image_save_to_file(char* filename, const uint8_t* image, size_t image_size,
427+
gpujpeg_image_save_to_file(const char* filename, const uint8_t* image, size_t image_size,
427428
const struct gpujpeg_image_parameters* param_image);
428429

429430
/**

src/gpujpeg_common.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1246,12 +1246,13 @@ set_file_extension(char *filename,
12461246

12471247
/* Documented at declaration */
12481248
int
1249-
gpujpeg_image_save_to_file(char* filename, const uint8_t* image, size_t image_size,
1249+
gpujpeg_image_save_to_file(const char* filename, const uint8_t* image, size_t image_size,
12501250
const struct gpujpeg_image_parameters* param_image)
12511251
{
12521252
if (strrchr(filename, '.') != NULL &&
12531253
strcmp(strrchr(filename, '.'), ".XXX") == 0) {
1254-
set_file_extension(filename, param_image);
1254+
// caller must ensure the filename to be mutable if ext is .XXX
1255+
set_file_extension((char *) filename, param_image);
12551256
}
12561257

12571258
enum gpujpeg_image_file_format format = gpujpeg_image_get_file_format(filename);

0 commit comments

Comments
 (0)