8297371: Improve UTF8 representation redux

Reviewed-by: yan, andrew
Backport-of: a44eb133d3cdb190abb0210c201e315d94d09dc7
This commit is contained in:
Martin Balao 2023-03-03 14:50:00 -05:00 committed by Andrew John Hughes
parent 6089a4fcc5
commit ed70f64af9

View File

@ -23,6 +23,7 @@
* questions.
*/
#include <limits.h>
#include <stdlib.h>
#include <string.h>
@ -33,8 +34,13 @@
* such as "z:" need to be appended with a "." so we
* must allocate at least 4 bytes to allow room for
* this expansion. See 4235353 for details.
* This macro returns NULL if the requested size is
* negative, or the size is INT_MAX as the macro adds 1
* that overflows into negative value.
*/
#define MALLOC_MIN4(len) ((char *)malloc((len) + 1 < 4 ? 4 : (len) + 1))
#define MALLOC_MIN4(len) ((unsigned)(len) >= INT_MAX ? \
NULL : \
((char *)malloc((len) + 1 < 4 ? 4 : (len) + 1)))
/**
* Throw a Java exception by name. Similar to SignalError.