11cb0ef41Sopenharmony_ci/*
21cb0ef41Sopenharmony_ci * nghttp2 - HTTP/2 C Library
31cb0ef41Sopenharmony_ci *
41cb0ef41Sopenharmony_ci * Copyright (c) 2014 Tatsuhiro Tsujikawa
51cb0ef41Sopenharmony_ci *
61cb0ef41Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining
71cb0ef41Sopenharmony_ci * a copy of this software and associated documentation files (the
81cb0ef41Sopenharmony_ci * "Software"), to deal in the Software without restriction, including
91cb0ef41Sopenharmony_ci * without limitation the rights to use, copy, modify, merge, publish,
101cb0ef41Sopenharmony_ci * distribute, sublicense, and/or sell copies of the Software, and to
111cb0ef41Sopenharmony_ci * permit persons to whom the Software is furnished to do so, subject to
121cb0ef41Sopenharmony_ci * the following conditions:
131cb0ef41Sopenharmony_ci *
141cb0ef41Sopenharmony_ci * The above copyright notice and this permission notice shall be
151cb0ef41Sopenharmony_ci * included in all copies or substantial portions of the Software.
161cb0ef41Sopenharmony_ci *
171cb0ef41Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
181cb0ef41Sopenharmony_ci * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
191cb0ef41Sopenharmony_ci * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
201cb0ef41Sopenharmony_ci * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
211cb0ef41Sopenharmony_ci * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
221cb0ef41Sopenharmony_ci * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
231cb0ef41Sopenharmony_ci * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
241cb0ef41Sopenharmony_ci */
251cb0ef41Sopenharmony_ci#include "nghttp2_mem.h"
261cb0ef41Sopenharmony_ci
271cb0ef41Sopenharmony_cistatic void *default_malloc(size_t size, void *mem_user_data) {
281cb0ef41Sopenharmony_ci  (void)mem_user_data;
291cb0ef41Sopenharmony_ci
301cb0ef41Sopenharmony_ci  return malloc(size);
311cb0ef41Sopenharmony_ci}
321cb0ef41Sopenharmony_ci
331cb0ef41Sopenharmony_cistatic void default_free(void *ptr, void *mem_user_data) {
341cb0ef41Sopenharmony_ci  (void)mem_user_data;
351cb0ef41Sopenharmony_ci
361cb0ef41Sopenharmony_ci  free(ptr);
371cb0ef41Sopenharmony_ci}
381cb0ef41Sopenharmony_ci
391cb0ef41Sopenharmony_cistatic void *default_calloc(size_t nmemb, size_t size, void *mem_user_data) {
401cb0ef41Sopenharmony_ci  (void)mem_user_data;
411cb0ef41Sopenharmony_ci
421cb0ef41Sopenharmony_ci  return calloc(nmemb, size);
431cb0ef41Sopenharmony_ci}
441cb0ef41Sopenharmony_ci
451cb0ef41Sopenharmony_cistatic void *default_realloc(void *ptr, size_t size, void *mem_user_data) {
461cb0ef41Sopenharmony_ci  (void)mem_user_data;
471cb0ef41Sopenharmony_ci
481cb0ef41Sopenharmony_ci  return realloc(ptr, size);
491cb0ef41Sopenharmony_ci}
501cb0ef41Sopenharmony_ci
511cb0ef41Sopenharmony_cistatic nghttp2_mem mem_default = {NULL, default_malloc, default_free,
521cb0ef41Sopenharmony_ci                                  default_calloc, default_realloc};
531cb0ef41Sopenharmony_ci
541cb0ef41Sopenharmony_cinghttp2_mem *nghttp2_mem_default(void) { return &mem_default; }
551cb0ef41Sopenharmony_ci
561cb0ef41Sopenharmony_civoid *nghttp2_mem_malloc(nghttp2_mem *mem, size_t size) {
571cb0ef41Sopenharmony_ci  return mem->malloc(size, mem->mem_user_data);
581cb0ef41Sopenharmony_ci}
591cb0ef41Sopenharmony_ci
601cb0ef41Sopenharmony_civoid nghttp2_mem_free(nghttp2_mem *mem, void *ptr) {
611cb0ef41Sopenharmony_ci  mem->free(ptr, mem->mem_user_data);
621cb0ef41Sopenharmony_ci}
631cb0ef41Sopenharmony_ci
641cb0ef41Sopenharmony_civoid nghttp2_mem_free2(nghttp2_free free_func, void *ptr, void *mem_user_data) {
651cb0ef41Sopenharmony_ci  free_func(ptr, mem_user_data);
661cb0ef41Sopenharmony_ci}
671cb0ef41Sopenharmony_ci
681cb0ef41Sopenharmony_civoid *nghttp2_mem_calloc(nghttp2_mem *mem, size_t nmemb, size_t size) {
691cb0ef41Sopenharmony_ci  return mem->calloc(nmemb, size, mem->mem_user_data);
701cb0ef41Sopenharmony_ci}
711cb0ef41Sopenharmony_ci
721cb0ef41Sopenharmony_civoid *nghttp2_mem_realloc(nghttp2_mem *mem, void *ptr, size_t size) {
731cb0ef41Sopenharmony_ci  return mem->realloc(ptr, size, mem->mem_user_data);
741cb0ef41Sopenharmony_ci}
75