Menu

Stupid problem: sync-fetch-sub returns different value than interlockeddecrement

This is the cause:
https://www.ibm.com/docs/vi/xcfbg/121.141?topic=functions-sync-fetch-sub
The function returns the initial value of the variable that __p points to.
https://learn.microsoft.com/en-us/windows/win32/api/winnt/nf-winnt-interlockeddecrement
The function returns the resulting decremented value.
:(

Different return value causes that on Windows no leak occurs, but on all unix systems
decreasing ussage counter does not cause releasing memory.
~~~
if(I->Raster!=NULL)
{
if(InterlockedDecrement(&I->Raster->UsageCount)<=0)
delete I->Raster;
I->Raster = NULL;
}
~~~

This will be fixed in WP2LaTeX-4.14

Posted by Jaroslav Fojtik 2025-03-02 Labels: bug

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.