Skip to content

Fix Memory Management for Printer Objects in CPDB API#83

Merged
tillkamppeter merged 1 commit intoOpenPrinting:masterfrom
prab0007al:dev2
Mar 19, 2025
Merged

Fix Memory Management for Printer Objects in CPDB API#83
tillkamppeter merged 1 commit intoOpenPrinting:masterfrom
prab0007al:dev2

Conversation

@prab0007al
Copy link

Description:

This pull request addresses issues related to double freeing and memory leaks in the CPDB library's printer object handling.

Changes Made:

As suggested by @tillkamppeter in issue itself, I have made the following changes:

  • Revised Memory Management: The responsibility for freeing printer objects has been moved from the callback function to the cpdbOnPrinterRemoved() function. This ensures that printer objects are freed immediately after the callback is executed.
  • Updated Callback Logic: Removed the printer object freeing from the cpdbPrinterCallback() function to prevent double-free errors when custom callbacks are used.

These changes enhance the reliability of the CPDB API and simplify its usage, ensuring developers no longer need to worry about memory management issues.

Fixes Issue #79 cpdbOnPrinterRemoved(): Free printer object directly, do not expect it from the callback

@tillkamppeter tillkamppeter merged commit ac27216 into OpenPrinting:master Mar 19, 2025
@prab0007al prab0007al deleted the dev2 branch March 29, 2025 18:00
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

Successfully merging this pull request may close these issues.

2 participants