Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question, why remove the list at the begin of function void mleakdetect_dump(int fd) #2

Open
NanFeng009 opened this issue Oct 27, 2023 · 1 comment

Comments

@NanFeng009
Copy link

Just enter into mleakdetect_dump function, you empty the mleakdetect_stat list. the later that list still be used?

	TAILQ_FOREACH_SAFE(m, &mleakdetect_stat, next, mt) {
		TAILQ_REMOVE(&mleakdetect_stat, m, next);
		mleakdetect_free(m);
	}

https://github.com/yasuoka/mleakdetect/blob/cc8d21119d505baf1693fa61053299decf996c55/mleakdetect.c#L426C1-L429C3

@yasuoka
Copy link
Owner

yasuoka commented Oct 29, 2023

The code preserves mleakdetect_stat after the mleakdetect_dump() is called. This intends that people can see the statistics with a debugger (maybe from core). And mleakdetect_dump() can be called multiple times. So the lines are to free mleakdetect_stat which was used when mleakdetect_dump() is called previously.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants