Skip to content

Commit 64d74bb

Browse files
committed
Give up on allocating callbacks with exact number. Allocate enough for
anything (for now). Fix later.
1 parent bd8e80b commit 64d74bb

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/can_common.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,10 @@ CAN_COMMON::CAN_COMMON(int numFilt)
6060
numFilters = numFilt;
6161
//Official entry for the worst, most convoluted looking C++ line ever written.
6262
//Dynamically allocate enough space for the function pointers with a hideous malloc call.
63-
*cbCANFrame = (void (*)(CAN_FRAME *))malloc(sizeof(void (*)(CAN_FRAME *)) * numFilters);
63+
//cbCANFrame = malloc(4 * numFilters);
64+
memset(cbCANFrame, 0, 4 * numFilters);
65+
cbGeneral = 0;
66+
for (int i = 0; i < SIZE_LISTENERS; i++) listener[i] = 0;
6467
}
6568

6669
uint32_t CAN_COMMON::begin()

src/can_common.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ class CAN_COMMON
131131
protected:
132132
CANListener *listener[SIZE_LISTENERS];
133133
void (*cbGeneral)(CAN_FRAME *); //general callback if no per-mailbox or per-filter entries matched
134-
void (**cbCANFrame)(CAN_FRAME *); //array of function pointers - disgusting syntax though.
134+
void (*cbCANFrame[16])(CAN_FRAME *); //array of function pointers - disgusting syntax though.
135135
uint32_t busSpeed;
136136
int numFilters;
137137
};

0 commit comments

Comments
 (0)