scuffed-code/icu4c/source/i18n/numsys_impl.h
Jeff Genovy d07396f94d
ICU-20041 Improve handling of OOM failures in NumberingSystem class. (#19)
ICU-20041 ICU4C NumberingSystem class doesn't handle out-of-memory (OOM) failures.

- Not all code paths in the NumberingSystem class check for OOM failures. This can lead to crashes in some cases as null pointers will be dereferenced without any checks.
- Change to use nullptr instead of NULL.
- Don't stomp on OOM errors when attempting to load resources. We should report back OOM to the caller.
- Use LocalPointer in order simplify the code and for automatic clean-up of memory.
- Use LocalUResourceBundlePointer as well to help simply things even more.
2018-09-27 14:27:37 -07:00

48 lines
1.3 KiB
C++

// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
*******************************************************************************
* Copyright (C) 2015, International Business Machines Corporation and
* others. All Rights Reserved. *
*******************************************************************************
*
* File NUMSYS_IMPL.H
*
*******************************************************************************
*/
#ifndef __NUMSYS_IMPL_H__
#define __NUMSYS_IMPL_H__
#include "unicode/utypes.h"
#if !UCONFIG_NO_FORMATTING
#include "unicode/numsys.h"
#include "uvector.h"
#include "unicode/strenum.h"
U_NAMESPACE_BEGIN
class NumsysNameEnumeration : public StringEnumeration {
public:
// NumsysNameEnumeration instance adopts numsysNames
NumsysNameEnumeration(UVector *numsysNames, UErrorCode& status);
virtual ~NumsysNameEnumeration();
static UClassID U_EXPORT2 getStaticClassID(void);
virtual UClassID getDynamicClassID(void) const;
virtual const UnicodeString* snext(UErrorCode& status);
virtual void reset(UErrorCode& status);
virtual int32_t count(UErrorCode& status) const;
private:
int32_t pos;
UVector *fNumsysNames = nullptr;
};
U_NAMESPACE_END
#endif
#endif