-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
request: json_init_library #540
Comments
If we're going to go through the trouble of changing every memory allocation, it would be worthwhile to also use a type-specific slab allocators for the struct json_object's, struct array_list's, struct lh_table's, etc... Then again, that's a rather more significant change. As for zeroizing sensitive buffers, if you're worried about that then it seems that merely changing the allocator used by json-c would be insufficient, as you'd be likely to have other allocations in your program that might have worthwhile-to-be-wiped content, in which case you should just replace malloc, free, etc... for the entire process. In short, I'm not actually convinced that overriding library-specific memory allocation in this way is worthwhile. |
@hawicz As you said, slab allocator is suitable for the fixed-size struct/object which is scheduled frequently indeed. It is a good optimization direction. I will try to implement this function 0.0. |
@dota17, before implementing anything a change like that is worth discussing in more detail. If you have some ideas about an existing allocator to bring in to json-c, please mention it on the json-c Google group, or in a separate github issue. |
@hawicz ok, I got it! |
I don't think there's anything to be done for this, so I'm closing it. |
Many libraries allow overriding
malloc
,realloc
, andfree
by (optionally) calling an initialization function. One of the use cases is to securely zeroize sensitive buffers. Currently, json-c uses platformmalloc
andfree
, which leaves all kinds of data (think: passwords) on the heap.I suggest to use new functions
json_malloc
etc. throughout the library, which default tomalloc
etc., but which can be set to user provided functions (only upon initialization). Currently, json-c also usesstrdup
, which could be replaced by an internal function that implements it using the newjson_malloc
.The text was updated successfully, but these errors were encountered: