Skip to content

Commit 41054c8

Browse files
committed
locale.c: Extend a static function
This will allow it to be used in situations where the buffer it controls is single use, and we don't need to keep track of the size for future calls.
1 parent 28e7ab0 commit 41054c8

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

embed.fnc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3226,7 +3226,7 @@ ST |const char*|my_langinfo|const int item|bool toggle
32263226
# endif
32273227
iTR |const char *|save_to_buffer|NULLOK const char * string \
32283228
|NULLOK const char **buf \
3229-
|NN Size_t *buf_size \
3229+
|NULLOK Size_t *buf_size \
32303230
|const Size_t offset
32313231
:# ifndef HAS_POSIX_2008_LOCALE
32323232
S |const char*|stdize_locale|const int category \

locale.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2609,7 +2609,10 @@ S_save_to_buffer(const char * string, const char **buf, Size_t *buf_size,
26092609

26102610
string_size = strlen(string) + offset + 1;
26112611

2612-
if (*buf_size == 0) {
2612+
if (buf_size == NULL) {
2613+
Newx(*buf, string_size, char);
2614+
}
2615+
else if (*buf_size == 0) {
26132616
Newx(*buf, string_size, char);
26142617
*buf_size = string_size;
26152618
}

proto.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5145,8 +5145,7 @@ STATIC void S_restore_switched_locale(pTHX_ const int category, const char * con
51455145
#ifndef PERL_NO_INLINE_FUNCTIONS
51465146
PERL_STATIC_INLINE const char * S_save_to_buffer(const char * string, const char **buf, Size_t *buf_size, const Size_t offset)
51475147
__attribute__warn_unused_result__;
5148-
#define PERL_ARGS_ASSERT_SAVE_TO_BUFFER \
5149-
assert(buf_size)
5148+
#define PERL_ARGS_ASSERT_SAVE_TO_BUFFER
51505149
#endif
51515150

51525151
STATIC void S_set_numeric_radix(pTHX_ const bool use_locale);

0 commit comments

Comments
 (0)