+// © 2016 and later: Unicode, Inc. and others.
+// License & terms of use: http://www.unicode.org/copyright.html
/*
**********************************************************************
- * Copyright (C) 2005-2006, International Business Machines
+ * Copyright (C) 2005-2016, International Business Machines
* Corporation and others. All Rights Reserved.
**********************************************************************
*/
#define BUFFER_SIZE 8192
-#define ARRAY_SIZE(array) (sizeof array / sizeof array[0])
-
#define NEW_ARRAY(type,count) (type *) uprv_malloc((count) * sizeof(type))
#define DELETE_ARRAY(array) uprv_free((void *) (array))
-InputText::InputText()
+InputText::InputText(UErrorCode &status)
: fInputBytes(NEW_ARRAY(uint8_t, BUFFER_SIZE)), // The text to be checked. Markup will have been
// removed if appropriate.
fByteStats(NEW_ARRAY(int16_t, 256)), // byte frequency statistics for the input text.
fDeclaredEncoding(0),
fRawInput(0),
fRawLength(0)
-{
-
+{
+ if (fInputBytes == NULL || fByteStats == NULL) {
+ status = U_MEMORY_ALLOCATION_ERROR;
+ }
}
InputText::~InputText()
fInputLen = 0;
fC1Bytes = FALSE;
fRawInput = (const uint8_t *) in;
- fRawLength = len == -1? uprv_strlen(in) : len;
+ fRawLength = len == -1? (int32_t)uprv_strlen(in) : len;
}
void InputText::setDeclaredEncoding(const char* encoding, int32_t len)
{
if(encoding) {
if (len == -1) {
- len = uprv_strlen(encoding);
+ len = (int32_t)uprv_strlen(encoding);
}
len += 1; // to make place for the \0 at the end.