s2j.c 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /*
  2. * This file is part of the struct2json Library.
  3. *
  4. * Copyright (c) 2015, Armink, <armink.ztl@gmail.com>
  5. *
  6. * Permission is hereby granted, free of charge, to any person obtaining
  7. * a copy of this software and associated documentation files (the
  8. * 'Software'), to deal in the Software without restriction, including
  9. * without limitation the rights to use, copy, modify, merge, publish,
  10. * distribute, sublicense, and/or sell copies of the Software, and to
  11. * permit persons to whom the Software is furnished to do so, subject to
  12. * the following conditions:
  13. *
  14. * The above copyright notice and this permission notice shall be
  15. * included in all copies or substantial portions of the Software.
  16. *
  17. * THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
  18. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  19. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  20. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
  21. * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  22. * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  23. * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  24. *
  25. * Function: Initialize interface for this library.
  26. * Created on: 2015-10-14
  27. */
  28. #include <s2j.h>
  29. #include <stdlib.h>
  30. #include <rtthread.h>
  31. S2jHook s2jHook = {
  32. .malloc_fn = (void *(*)(size_t sz))rt_malloc,
  33. .free_fn = rt_free,
  34. };
  35. /**
  36. * struct2json library initialize
  37. * @note It will initialize cJSON library hooks.
  38. */
  39. //void s2j_init(S2jHook *hook) {
  40. // /* initialize cJSON library */
  41. // cJSON_InitHooks((cJSON_Hooks *)hook);
  42. // /* initialize hooks */
  43. // if (hook) {
  44. // s2jHook.malloc_fn = (hook->malloc_fn)?hook->malloc_fn : rt_malloc;
  45. // s2jHook.free_fn = (hook->free_fn) ? hook->free_fn : rt_malloc;
  46. // } else {
  47. // hook->malloc_fn = rt_malloc;
  48. // hook->free_fn = rt_malloc;
  49. // }
  50. //}