Skip to content

Commit

Permalink
locale.c: Extend a static function
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
khwilliamson committed May 9, 2021
1 parent e6ad725 commit f0054bc
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion embed.fnc
Expand Up @@ -3226,7 +3226,7 @@ ST |const char*|my_langinfo|const int item|bool toggle
# endif
iTR |const char *|save_to_buffer|NULLOK const char * string \
|NULLOK const char **buf \
|NN Size_t *buf_size \
|NULLOK Size_t *buf_size \
|const Size_t offset
:# ifndef HAS_POSIX_2008_LOCALE
S |const char*|stdize_locale|const int category \
Expand Down
5 changes: 4 additions & 1 deletion locale.c
Expand Up @@ -2623,7 +2623,10 @@ S_save_to_buffer(const char * string, const char **buf, Size_t *buf_size,

string_size = strlen(string) + offset + 1;

if (*buf_size == 0) {
if (buf_size == NULL) {
Newx(*buf, string_size, char);
}
else if (*buf_size == 0) {
Newx(*buf, string_size, char);
*buf_size = string_size;
}
Expand Down
3 changes: 1 addition & 2 deletions proto.h
Expand Up @@ -5145,8 +5145,7 @@ STATIC void S_restore_switched_locale(pTHX_ const int category, const char * con
#ifndef PERL_NO_INLINE_FUNCTIONS
PERL_STATIC_INLINE const char * S_save_to_buffer(const char * string, const char **buf, Size_t *buf_size, const Size_t offset)
__attribute__warn_unused_result__;
#define PERL_ARGS_ASSERT_SAVE_TO_BUFFER \
assert(buf_size)
#define PERL_ARGS_ASSERT_SAVE_TO_BUFFER
#endif

STATIC void S_set_numeric_radix(pTHX_ const bool use_locale);
Expand Down

0 comments on commit f0054bc

Please sign in to comment.