btstack_memory.c (27faf85a90e36a8a692d1a6aa0922e476bf2d728) btstack_memory.c (0e826a176164f342e7049a881289eee255b51b64)
1/*
2 * Copyright (C) 2014 BlueKitchen GmbH
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright

--- 463 unchanged lines hidden (view full) ---

472}
473void btstack_memory_service_record_item_free(service_record_item_t *service_record_item){
474 free(service_record_item);
475}
476#endif
477
478
479
1/*
2 * Copyright (C) 2014 BlueKitchen GmbH
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright

--- 463 unchanged lines hidden (view full) ---

472}
473void btstack_memory_service_record_item_free(service_record_item_t *service_record_item){
474 free(service_record_item);
475}
476#endif
477
478
479
480// MARK: avdtp_sink_connection_t
481#if !defined(HAVE_MALLOC) && !defined(MAX_NR_AVDTP_SINK_CONNECTIONS)
482 #if defined(MAX_NO_AVDTP_SINK_CONNECTIONS)
483 #error "Deprecated MAX_NO_AVDTP_SINK_CONNECTIONS defined instead of MAX_NR_AVDTP_SINK_CONNECTIONS. Please update your btstack_config.h to use MAX_NR_AVDTP_SINK_CONNECTIONS."
480// MARK: avdtp_stream_endpoint_t
481#if !defined(HAVE_MALLOC) && !defined(MAX_NR_AVDTP_STREAM_ENDPOINTS)
482 #if defined(MAX_NO_AVDTP_STREAM_ENDPOINTS)
483 #error "Deprecated MAX_NO_AVDTP_STREAM_ENDPOINTS defined instead of MAX_NR_AVDTP_STREAM_ENDPOINTS. Please update your btstack_config.h to use MAX_NR_AVDTP_STREAM_ENDPOINTS."
484 #else
484 #else
485 #define MAX_NR_AVDTP_SINK_CONNECTIONS 0
485 #define MAX_NR_AVDTP_STREAM_ENDPOINTS 0
486 #endif
487#endif
488
486 #endif
487#endif
488
489#ifdef MAX_NR_AVDTP_SINK_CONNECTIONS
490#if MAX_NR_AVDTP_SINK_CONNECTIONS > 0
491static avdtp_sink_connection_t avdtp_sink_connection_storage[MAX_NR_AVDTP_SINK_CONNECTIONS];
492static btstack_memory_pool_t avdtp_sink_connection_pool;
493avdtp_sink_connection_t * btstack_memory_avdtp_sink_connection_get(void){
494 return (avdtp_sink_connection_t *) btstack_memory_pool_get(&avdtp_sink_connection_pool);
489#ifdef MAX_NR_AVDTP_STREAM_ENDPOINTS
490#if MAX_NR_AVDTP_STREAM_ENDPOINTS > 0
491static avdtp_stream_endpoint_t avdtp_stream_endpoint_storage[MAX_NR_AVDTP_STREAM_ENDPOINTS];
492static btstack_memory_pool_t avdtp_stream_endpoint_pool;
493avdtp_stream_endpoint_t * btstack_memory_avdtp_stream_endpoint_get(void){
494 return (avdtp_stream_endpoint_t *) btstack_memory_pool_get(&avdtp_stream_endpoint_pool);
495}
495}
496void btstack_memory_avdtp_sink_connection_free(avdtp_sink_connection_t *avdtp_sink_connection){
497 btstack_memory_pool_free(&avdtp_sink_connection_pool, avdtp_sink_connection);
496void btstack_memory_avdtp_stream_endpoint_free(avdtp_stream_endpoint_t *avdtp_stream_endpoint){
497 btstack_memory_pool_free(&avdtp_stream_endpoint_pool, avdtp_stream_endpoint);
498}
499#else
498}
499#else
500avdtp_sink_connection_t * btstack_memory_avdtp_sink_connection_get(void){
500avdtp_stream_endpoint_t * btstack_memory_avdtp_stream_endpoint_get(void){
501 return NULL;
502}
501 return NULL;
502}
503void btstack_memory_avdtp_sink_connection_free(avdtp_sink_connection_t *avdtp_sink_connection){
503void btstack_memory_avdtp_stream_endpoint_free(avdtp_stream_endpoint_t *avdtp_stream_endpoint){
504 // silence compiler warning about unused parameter in a portable way
504 // silence compiler warning about unused parameter in a portable way
505 (void) avdtp_sink_connection;
505 (void) avdtp_stream_endpoint;
506};
507#endif
508#elif defined(HAVE_MALLOC)
506};
507#endif
508#elif defined(HAVE_MALLOC)
509avdtp_sink_connection_t * btstack_memory_avdtp_sink_connection_get(void){
510 return (avdtp_sink_connection_t*) malloc(sizeof(avdtp_sink_connection_t));
509avdtp_stream_endpoint_t * btstack_memory_avdtp_stream_endpoint_get(void){
510 return (avdtp_stream_endpoint_t*) malloc(sizeof(avdtp_stream_endpoint_t));
511}
511}
512void btstack_memory_avdtp_sink_connection_free(avdtp_sink_connection_t *avdtp_sink_connection){
513 free(avdtp_sink_connection);
512void btstack_memory_avdtp_stream_endpoint_free(avdtp_stream_endpoint_t *avdtp_stream_endpoint){
513 free(avdtp_stream_endpoint);
514}
515#endif
516
517
518#ifdef ENABLE_BLE
519
520// MARK: gatt_client_t
521#if !defined(HAVE_MALLOC) && !defined(MAX_NR_GATT_CLIENTS)

--- 140 unchanged lines hidden (view full) ---

662 btstack_memory_pool_create(&bnep_channel_pool, bnep_channel_storage, MAX_NR_BNEP_CHANNELS, sizeof(bnep_channel_t));
663#endif
664#if MAX_NR_HFP_CONNECTIONS > 0
665 btstack_memory_pool_create(&hfp_connection_pool, hfp_connection_storage, MAX_NR_HFP_CONNECTIONS, sizeof(hfp_connection_t));
666#endif
667#if MAX_NR_SERVICE_RECORD_ITEMS > 0
668 btstack_memory_pool_create(&service_record_item_pool, service_record_item_storage, MAX_NR_SERVICE_RECORD_ITEMS, sizeof(service_record_item_t));
669#endif
514}
515#endif
516
517
518#ifdef ENABLE_BLE
519
520// MARK: gatt_client_t
521#if !defined(HAVE_MALLOC) && !defined(MAX_NR_GATT_CLIENTS)

--- 140 unchanged lines hidden (view full) ---

662 btstack_memory_pool_create(&bnep_channel_pool, bnep_channel_storage, MAX_NR_BNEP_CHANNELS, sizeof(bnep_channel_t));
663#endif
664#if MAX_NR_HFP_CONNECTIONS > 0
665 btstack_memory_pool_create(&hfp_connection_pool, hfp_connection_storage, MAX_NR_HFP_CONNECTIONS, sizeof(hfp_connection_t));
666#endif
667#if MAX_NR_SERVICE_RECORD_ITEMS > 0
668 btstack_memory_pool_create(&service_record_item_pool, service_record_item_storage, MAX_NR_SERVICE_RECORD_ITEMS, sizeof(service_record_item_t));
669#endif
670#if MAX_NR_AVDTP_SINK_CONNECTIONS > 0
671 btstack_memory_pool_create(&avdtp_sink_connection_pool, avdtp_sink_connection_storage, MAX_NR_AVDTP_SINK_CONNECTIONS, sizeof(avdtp_sink_connection_t));
670#if MAX_NR_AVDTP_STREAM_ENDPOINTS > 0
671 btstack_memory_pool_create(&avdtp_stream_endpoint_pool, avdtp_stream_endpoint_storage, MAX_NR_AVDTP_STREAM_ENDPOINTS, sizeof(avdtp_stream_endpoint_t));
672#endif
673#ifdef ENABLE_BLE
674#if MAX_NR_GATT_CLIENTS > 0
675 btstack_memory_pool_create(&gatt_client_pool, gatt_client_storage, MAX_NR_GATT_CLIENTS, sizeof(gatt_client_t));
676#endif
677#if MAX_NR_WHITELIST_ENTRIES > 0
678 btstack_memory_pool_create(&whitelist_entry_pool, whitelist_entry_storage, MAX_NR_WHITELIST_ENTRIES, sizeof(whitelist_entry_t));
679#endif
680#if MAX_NR_SM_LOOKUP_ENTRIES > 0
681 btstack_memory_pool_create(&sm_lookup_entry_pool, sm_lookup_entry_storage, MAX_NR_SM_LOOKUP_ENTRIES, sizeof(sm_lookup_entry_t));
682#endif
683#endif
684}
672#endif
673#ifdef ENABLE_BLE
674#if MAX_NR_GATT_CLIENTS > 0
675 btstack_memory_pool_create(&gatt_client_pool, gatt_client_storage, MAX_NR_GATT_CLIENTS, sizeof(gatt_client_t));
676#endif
677#if MAX_NR_WHITELIST_ENTRIES > 0
678 btstack_memory_pool_create(&whitelist_entry_pool, whitelist_entry_storage, MAX_NR_WHITELIST_ENTRIES, sizeof(whitelist_entry_t));
679#endif
680#if MAX_NR_SM_LOOKUP_ENTRIES > 0
681 btstack_memory_pool_create(&sm_lookup_entry_pool, sm_lookup_entry_storage, MAX_NR_SM_LOOKUP_ENTRIES, sizeof(sm_lookup_entry_t));
682#endif
683#endif
684}