vivkin / gason

Lightweight and fast JSON parser for C++
MIT License
338 stars 51 forks source link

prevent memory growing #8

Closed azadkuh closed 10 years ago

azadkuh commented 10 years ago

it's better to add:

allocator.deallocate();

to the bigining of jsonParse() to stop allocator instance growing every time if the instance has been used before.

users may forget to call deallocate() or introduce a new instance of allocator every time they call jsonParse().

vivkin commented 10 years ago

No it's not. User is smart enough to care about memory. Parser just parsing, instead solving memory management issues

azadkuh commented 10 years ago

definitely users are smart!

one of the key Characteristics of a Good API is Hard to misuse regardless of users intelligence.

because they are focused on their own logic / application and they may have no time to fully understand your great implementation.

another approach: jsonParse() can return an error status code if allocator is already allocated.

vivkin commented 10 years ago

In allocator maybe allocated buffer for copy of source buffer or something similar