*/
/* IOMemoryCursor.cpp created by wgulland on 1999-3-02 */
+#define IOKIT_ENABLE_SHARED_PTR
+
#include <IOKit/assert.h>
#include <IOKit/IOLib.h>
#include <IOKit/IOMemoryCursor.h>
#define super OSObject
OSDefineMetaClassAndStructors(IOMemoryCursor, OSObject)
-IOMemoryCursor *
+OSSharedPtr<IOMemoryCursor>
IOMemoryCursor::withSpecification(SegmentFunction inSegFunc,
IOPhysicalLength inMaxSegmentSize,
IOPhysicalLength inMaxTransferSize,
IOPhysicalLength inAlignment)
{
- IOMemoryCursor * me = new IOMemoryCursor;
+ OSSharedPtr<IOMemoryCursor> me = OSMakeShared<IOMemoryCursor>();
if (me && !me->initWithSpecification(inSegFunc,
inMaxSegmentSize,
inMaxTransferSize,
inAlignment)) {
- me->release();
- return 0;
+ return nullptr;
}
return me;
if (!inSegFunc) {
return false;
}
+ if (inMaxTransferSize > UINT_MAX) {
+ return false;
+ }
outSeg = inSegFunc;
maxSegmentSize = inMaxSegmentSize;
}
if (!inMaxTransferSize) {
- inMaxTransferSize = maxTransferSize;
+ inMaxTransferSize = (typeof(inMaxTransferSize))maxTransferSize;
}
/*
((PhysicalSegment *) outSegments)[outSegmentIndex] = segment;
}
-IONaturalMemoryCursor *
+OSSharedPtr<IONaturalMemoryCursor>
IONaturalMemoryCursor::withSpecification(IOPhysicalLength inMaxSegmentSize,
IOPhysicalLength inMaxTransferSize,
IOPhysicalLength inAlignment)
{
- IONaturalMemoryCursor *me = new IONaturalMemoryCursor;
+ OSSharedPtr<IONaturalMemoryCursor> me = OSMakeShared<IONaturalMemoryCursor>();
if (me && !me->initWithSpecification(inMaxSegmentSize,
inMaxTransferSize,
inAlignment)) {
- me->release();
- return 0;
+ return nullptr;
}
return me;
#endif
}
-IOBigMemoryCursor *
+OSSharedPtr<IOBigMemoryCursor>
IOBigMemoryCursor::withSpecification(IOPhysicalLength inMaxSegmentSize,
IOPhysicalLength inMaxTransferSize,
IOPhysicalLength inAlignment)
{
- IOBigMemoryCursor * me = new IOBigMemoryCursor;
+ OSSharedPtr<IOBigMemoryCursor> me = OSMakeShared<IOBigMemoryCursor>();
if (me && !me->initWithSpecification(inMaxSegmentSize,
inMaxTransferSize,
inAlignment)) {
- me->release();
- return 0;
+ return nullptr;
}
return me;
#endif
}
-IOLittleMemoryCursor *
+OSSharedPtr<IOLittleMemoryCursor>
IOLittleMemoryCursor::withSpecification(IOPhysicalLength inMaxSegmentSize,
IOPhysicalLength inMaxTransferSize,
IOPhysicalLength inAlignment)
{
- IOLittleMemoryCursor * me = new IOLittleMemoryCursor;
+ OSSharedPtr<IOLittleMemoryCursor> me = OSMakeShared<IOLittleMemoryCursor>();
if (me && !me->initWithSpecification(inMaxSegmentSize,
inMaxTransferSize,
inAlignment)) {
- me->release();
- return 0;
+ return nullptr;
}
return me;