1
0

fix memoy leak of crc msg

still don't work with time
This commit is contained in:
Rémi Heredero 2024-04-24 17:20:16 +02:00
parent a0ce103a16
commit f9b4ecb42c
Signed by: Klagarge
GPG Key ID: 3CBAC2C6CD1E8807
4 changed files with 34 additions and 49 deletions

View File

@ -126,10 +126,12 @@ void MacSender(void *argument) {
} else { } else {
// Checksum error, send original message again // Checksum error, send original message again
if(lastSentMsgPtr != NULL) { if(lastSentMsgPtr != NULL) {
retCode = osMemoryPoolFree(memPool, queueMsg.anyPtr); //retCode = osMemoryPoolFree(memPool, queueMsg.anyPtr);
CheckRetCode(retCode, __LINE__, __FILE__, CONTINUE); //CheckRetCode(retCode, __LINE__, __FILE__, CONTINUE);
memcpy(queueMsg.anyPtr, lastSentMsgPtr, sizeof(lastSentMsgPtr));
queueMsg.type = TO_PHY; queueMsg.type = TO_PHY;
queueMsg.anyPtr = lastSentMsgPtr; //queueMsg.anyPtr = lastSentMsgPtr;
retCode = osMessageQueuePut( retCode = osMessageQueuePut(
queue_phyS_id, queue_phyS_id,
&queueMsg, &queueMsg,
@ -240,7 +242,7 @@ void MacSender(void *argument) {
msg = osMemoryPoolAlloc(memPool, 0); // TODO - Leak of memory msg = osMemoryPoolAlloc(memPool, 0); // TODO - Leak of memory
if(msg == NULL) { if(msg == NULL) {
printf("Memory allocation failed\r\n"); printf("Memory allocation failed #1\r\n");
assert(false); assert(false);
} }
msg[0] = src.raw; msg[0] = src.raw;
@ -254,8 +256,15 @@ void MacSender(void *argument) {
CheckRetCode(retCode, __LINE__, __FILE__, CONTINUE); CheckRetCode(retCode, __LINE__, __FILE__, CONTINUE);
if(dst.addr != BROADCAST_ADDRESS) { if(dst.addr != BROADCAST_ADDRESS) {
lastSentMsgPtr = osMemoryPoolAlloc(memPool, osWaitForever); if(dst.sapi == CHAT_SAPI) {
memcpy(lastSentMsgPtr, msg, length+4); lastSentMsgPtr = osMemoryPoolAlloc(memPool, 0);
if(lastSentMsgPtr == NULL) {
printf("Memory allocation failed #2\r\n");
assert(false);
}
memcpy(lastSentMsgPtr, msg, length+4);
// TODO test if station is online
}
} }
queueMsg.anyPtr = msg; queueMsg.anyPtr = msg;

14
main.h
View File

@ -139,3 +139,17 @@ typedef union {
}; };
uint8_t raw; uint8_t raw;
} Status; } Status;
typedef union {
struct {
bool_t nothing0: 1; // MSB
bool_t chat: 1;
bool_t nothing2: 1;
bool_t time: 1;
bool_t nothing4: 1;
bool_t nothing5: 1;
bool_t nothing6: 1;
bool_t nothing7: 1; // LSB
};
uint8_t raw;
} SapiToken;

View File

@ -120,7 +120,7 @@
<SetRegEntry> <SetRegEntry>
<Number>0</Number> <Number>0</Number>
<Key>EVENTREC_CNF</Key> <Key>EVENTREC_CNF</Key>
<Name>-l2 -a1 -s0 -f0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000</Name> <Name>-l0 -a1 -s0 -f0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000</Name>
</SetRegEntry> </SetRegEntry>
<SetRegEntry> <SetRegEntry>
<Number>0</Number> <Number>0</Number>
@ -145,7 +145,7 @@
<SetRegEntry> <SetRegEntry>
<Number>0</Number> <Number>0</Number>
<Key>ST-LINKIII-KEIL_SWO</Key> <Key>ST-LINKIII-KEIL_SWO</Key>
<Name>-U066DFF485153826687131237 -O8398 -SF10000 -C0 -A0 -I0 -HNlocalhost -HP7184 -P2 -N00("ARM CoreSight SW-DP (ARM Core") -D00(5BA02477) -L00(0) -TO131075 -TC216000000 -TT216000000 -TP21 -TDS806B -TDT0 -TDC1F -TIE1 -TIP1 -FO7 -FD20010000 -FC1000 -FN1 -FF0STM32F7x_1024.FLM -FS08000000 -FL0100000 -FP0($$Device:STM32F746NGHx$CMSIS\Flash\STM32F7x_1024.FLM) -WA0 -WE0 -WVCE4 -WS2710 -WM0 -WP2</Name> <Name>-U066DFF485153826687131237 -O8398 -SF1800 -C0 -A0 -I2 -HNlocalhost -HP7184 -P2 -N00("ARM CoreSight SW-DP (ARM Core") -D00(5BA02477) -L00(0) -TO131075 -TC216000000 -TT216000000 -TP21 -TDS806B -TDT0 -TDC1F -TIE1 -TIP1 -FO7 -FD20010000 -FC1000 -FN1 -FF0STM32F7x_1024.FLM -FS08000000 -FL0100000 -FP0($$Device:STM32F746NGHx$CMSIS\Flash\STM32F7x_1024.FLM) -WA0 -WE0 -WVCE4 -WS2710 -WM0 -WP2</Name>
</SetRegEntry> </SetRegEntry>
<SetRegEntry> <SetRegEntry>
<Number>0</Number> <Number>0</Number>
@ -153,40 +153,7 @@
<Name>UL2CM3(-S0 -C0 -P0 -FD20010000 -FC1000 -FN1 -FF0STM32F7x_1024 -FS08000000 -FL0100000 -FP0($$Device:STM32F746NGHx$CMSIS\Flash\STM32F7x_1024.FLM))</Name> <Name>UL2CM3(-S0 -C0 -P0 -FD20010000 -FC1000 -FN1 -FF0STM32F7x_1024 -FS08000000 -FL0100000 -FP0($$Device:STM32F746NGHx$CMSIS\Flash\STM32F7x_1024.FLM))</Name>
</SetRegEntry> </SetRegEntry>
</TargetDriverDllRegistry> </TargetDriverDllRegistry>
<Breakpoint> <Breakpoint/>
<Bp>
<Number>0</Number>
<Type>0</Type>
<LineNumber>18</LineNumber>
<EnabledFlag>1</EnabledFlag>
<Address>134311210</Address>
<ByteObject>0</ByteObject>
<HtxType>0</HtxType>
<ManyObjects>0</ManyObjects>
<SizeOfObject>0</SizeOfObject>
<BreakByAccess>0</BreakByAccess>
<BreakIfRCount>1</BreakIfRCount>
<Filename>.\mac_receiver.c</Filename>
<ExecCommand></ExecCommand>
<Expression>\\tokenring_project\mac_receiver.c\18</Expression>
</Bp>
<Bp>
<Number>1</Number>
<Type>0</Type>
<LineNumber>199</LineNumber>
<EnabledFlag>1</EnabledFlag>
<Address>0</Address>
<ByteObject>0</ByteObject>
<HtxType>0</HtxType>
<ManyObjects>0</ManyObjects>
<SizeOfObject>0</SizeOfObject>
<BreakByAccess>0</BreakByAccess>
<BreakIfRCount>0</BreakIfRCount>
<Filename>.\main.c</Filename>
<ExecCommand></ExecCommand>
<Expression></Expression>
</Bp>
</Breakpoint>
<WatchWindow1> <WatchWindow1>
<Ww> <Ww>
<count>0</count> <count>0</count>
@ -208,11 +175,6 @@
<WinNumber>1</WinNumber> <WinNumber>1</WinNumber>
<ItemText>lastToken</ItemText> <ItemText>lastToken</ItemText>
</Ww> </Ww>
<Ww>
<count>4</count>
<WinNumber>1</WinNumber>
<ItemText>queue_macData_id</ItemText>
</Ww>
</WatchWindow1> </WatchWindow1>
<MemoryWindow1> <MemoryWindow1>
<Mm> <Mm>
@ -287,7 +249,7 @@
<EnableFlashSeq>0</EnableFlashSeq> <EnableFlashSeq>0</EnableFlashSeq>
<EnableLog>0</EnableLog> <EnableLog>0</EnableLog>
<Protocol>2</Protocol> <Protocol>2</Protocol>
<DbgClock>10000000</DbgClock> <DbgClock>1800000</DbgClock>
</DebugDescription> </DebugDescription>
</TargetOption> </TargetOption>
</Target> </Target>

View File

@ -10,7 +10,7 @@
<TargetName>Target 1</TargetName> <TargetName>Target 1</TargetName>
<ToolsetNumber>0x4</ToolsetNumber> <ToolsetNumber>0x4</ToolsetNumber>
<ToolsetName>ARM-ADS</ToolsetName> <ToolsetName>ARM-ADS</ToolsetName>
<pCCUsed>5060960::V5.06 update 7 (build 960)::C:\Program Files (x86)\ARM_Compiler_5.06u7</pCCUsed> <pCCUsed>5060960::V5.06 update 7 (build 960)::..\..\Program Files (x86)\ARM_Compiler_5.06u7</pCCUsed>
<uAC6>0</uAC6> <uAC6>0</uAC6>
<TargetOption> <TargetOption>
<TargetCommonOption> <TargetCommonOption>