2 * Copyright 2010, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Distributed under the terms of the MIT License.
7 #include <extended_system_info.h>
8 #include <extended_system_info_defs.h>
11 #include <AutoDeleter.h>
13 #include <util/KMessage.h>
20 get_extended_team_info(team_id teamID
, uint32 flags
, KMessage
& info
)
22 // initial buffer size
23 size_t bufferSize
= 4096;
24 // TODO: Pick it depending on the set flags.
27 // allocate the buffer
28 void* buffer
= malloc(bufferSize
);
31 MemoryDeleter
bufferDeleter(buffer
);
35 status_t error
= _kern_get_extended_team_info(teamID
, flags
, buffer
,
36 bufferSize
, &sizeNeeded
);
38 return info
.SetTo((const void*)buffer
, sizeNeeded
,
39 KMessage::KMESSAGE_CLONE_BUFFER
);
40 // TODO: Just transfer our buffer, if it isn't much larger.
43 if (error
!= B_BUFFER_OVERFLOW
)
46 // The buffer was too small. Try again with a larger one.
47 bufferSize
= (sizeNeeded
+ 1023) / 1024 * 1024;
52 } // namespace BPrivate