Files
hmmmm/inc/context.h
root 71ec472510 fix: code quality improvements across C codebase
- Replace sprintf with snprintf (1024-byte errbuf) in hmmmm.c, base_device.c,
  compose_device.c, config.c
- Fix WRITE_MEM macro: use smartAddrWriteHandlers for write ident (was
  incorrectly reading from smartAddrReadHandlers)
- Replace alloca with malloc+free in dispatchMemAccessNotifications
- Guard closeBaseDevice against NULL lib/partial initialization
- Simplify intercept context storage to single contiguous allocation
- Add NULL checks after calloc in config handler with proper cleanup
- Guard find_device_by_id against zero-length path

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-01 22:18:23 +00:00

50 lines
1.1 KiB
C

#ifndef __CONTEXT_H__
#define __CONTEXT_H__
#include <pthread.h>
#include "ptQueue/inc/ptQueue.h"
#include "wsServer/include/ws.h"
#include "linkedlist.h"
#include "sized_ptr.h"
#include "streamed.h"
#include "flatcc/flatcc_builder.h"
typedef struct {
SizedPtr* bufs;
uint8_t buffersCount;
_Atomic (uint8_t) readRequestIdx;
_Atomic (uint8_t) currWritingIdx;
} OutgoingBuffers;
typedef struct {
uint8_t* emulState;
uint64_t* clockCounter;
LinkedListEntry** clientsHead;
uint8_t* utilizedFlag;
OutgoingBuffers* outBufs;
DeviceSegStreamReg** deviceStreamRegs;
uint8_t** devicesMem;
size_t devicesCount;
void** deviceHandles; // device_handle_t** — dynamically loaded devices
void* interceptCtxs; // contiguous intercept_ctx_t array (freed as single block)
size_t interceptCtxCount;
flatcc_builder_t stream_builder;
} EmulContext;
typedef struct {
pthread_mutex_t registerMutex;
ptQueue* regQueue;
uint8_t* accessToken;
EmulContext* emulContext;
} ServerContext;
#endif //ifndef __CONTEXT_H__