ClientMemoryAllocator: use map and reference count

- Resolve TODO about using map for server area_id lookup.

- Remove server cloned area delete request logic because it is less
  efficient and robust. Cloned area delete request messages may be
  missed if client message queue is full so it may cause cloned area
  leak.

- Implement reference counting for cloned areas instead.

Change-Id: Ie434ad36c2761ab0df00d341d55a6cea67b69830
Reviewed-on: https://review.haiku-os.org/c/haiku/+/9667
Reviewed-by: waddlesplash <[email protected]>
Tested-by: Commit checker robot <[email protected]>
This commit is contained in:
X512
2025-10-06 15:10:48 +00:00
committed by waddlesplash
parent 5247c8c14f
commit 47538c534f
10 changed files with 73 additions and 130 deletions
+12 -5
View File
@@ -9,13 +9,22 @@
#define SERVER_MEMORY_ALLOCATOR_H
#include <map>
#include <OS.h>
#include <List.h>
namespace BPrivate {
struct area_mapping {
int32 reference_count;
area_id server_area;
area_id local_area;
uint8* local_base;
};
class ServerMemoryAllocator {
public:
ServerMemoryAllocator();
@@ -28,11 +37,9 @@ public:
bool readOnly = false);
void RemoveArea(area_id serverArea);
status_t AreaAndBaseFor(area_id serverArea,
area_id& area, uint8*& base);
private:
BList fAreas;
std::map<area_id, area_mapping>
fAreas;
};
-7
View File
@@ -377,18 +377,11 @@ enum {
AS_LAST_CODE
};
// TODO: move this into a private app header, together with the rest of the
// private message definitions in AppDefs.h
enum {
kMsgDeleteServerMemoryArea = '_DSA',
};
// bitmap allocation flags
enum {
kAllocator = 0x1,
kFramebuffer = 0x2,
kHeap = 0x4,
kNewAllocatorArea = 0x8,
};
#endif // APP_SERVER_PROTOCOL_H