Skip to content

Conversation

redboltz
Copy link
Contributor

@redboltz redboltz commented Feb 1, 2014

#52

@redboltz
Copy link
Contributor Author

redboltz commented Feb 1, 2014

This is a little bit tricky fix. The problem is that the memory allocated by ::malloc() in the C part of the msgpack-c is deallocated by operator delete via auto_ptr. So I added the custom operator delete() that deallocates the given memory by ::free(). Also I added the custom operator new() that allocates the memory by ::malloc(). As the result of this fix, the memory allocated at both the C part of the msgpack-c and 'new zone' in the C++ code are allocated by ::malloc() and deallocated by ::free().

I intentionaly choose operator delete without size version because allocated memory should be freed by ::free() regardless its size.

@redboltz
Copy link
Contributor Author

redboltz commented Feb 2, 2014

Thanks! You are right, vvolodko. I updated my pull request.

@nobu-k
Copy link
Member

nobu-k commented Feb 7, 2014

Thanks! I tested this change with several sample codes and confirmed warnings were removed.

nobu-k added a commit that referenced this pull request Feb 7, 2014
Fixed the free and delete mismatch problem.
@nobu-k nobu-k merged commit ca24e04 into msgpack:master Feb 7, 2014
@redboltz redboltz deleted the fix_delete_free_mismatch branch March 31, 2014 08:54
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.

3 participants