#include "lwip/opt.h"
Include dependency graph for memp.h:
This graph shows which files directly or indirectly include this file:
Go to the source code of this file.
Enumerations | |
enum | memp_t { MEMP_PBUF, MEMP_UDP_PCB, MEMP_TCP_PCB, MEMP_TCP_PCB_LISTEN, MEMP_TCP_SEG, MEMP_NETBUF, MEMP_NETCONN, MEMP_API_MSG, MEMP_TCPIP_MSG, MEMP_MAX } |
Functions | |
void | memp_init (void) |
void * | memp_malloc (memp_t type) |
void * | memp_realloc (memp_t fromtype, memp_t totype, void *mem) |
void | memp_free (memp_t type, void *mem) |
void * | memp_mallocp (memp_t type) |
void | memp_freep (memp_t type, void *mem) |
|
Definition at line 38 of file memp.h.
00038 { 00039 MEMP_PBUF, 00040 MEMP_UDP_PCB, 00041 MEMP_TCP_PCB, 00042 MEMP_TCP_PCB_LISTEN, 00043 MEMP_TCP_SEG, 00044 00045 MEMP_NETBUF, 00046 MEMP_NETCONN, 00047 MEMP_API_MSG, 00048 MEMP_TCPIP_MSG, 00049 00050 00051 MEMP_MAX 00052 } memp_t; |
|
Definition at line 238 of file memp.c. References LWIP_ASSERT, memp_tab, NULL, and u8_t. Referenced by memp_freep(), netconn_delete(), and tcpip_apimsg().
00239 { 00240 struct memp *memp; 00241 00242 if(mem == NULL) { 00243 return; 00244 } 00245 memp = (struct memp *)((u8_t *)mem - sizeof(struct memp)); 00246 00247 #ifdef MEMP_STATS 00248 lwip_stats.memp[type].used--; 00249 #endif /* MEMP_STATS */ 00250 00251 memp->next = memp_tab[type]; 00252 memp_tab[type] = memp; 00253 00254 LWIP_ASSERT("memp sanity", memp_sanity()); 00255 00256 return; 00257 } |
|
Definition at line 260 of file memp.c. References memp_free(), mutex, sys_sem_signal(), and sys_sem_wait(). Referenced by netbuf_chain(), netbuf_delete(), netconn_bind(), netconn_close(), netconn_connect(), netconn_delete(), netconn_disconnect(), netconn_listen(), netconn_new(), netconn_recv(), netconn_send(), netconn_write(), pbuf_free(), and tcpip_thread().
00261 { 00262 #if SYS_LIGHTWEIGHT_PROT 00263 SYS_ARCH_DECL_PROTECT(old_level); 00264 SYS_ARCH_PROTECT(old_level); 00265 #else /* SYS_LIGHTWEIGHT_PROT */ 00266 sys_sem_wait(mutex); 00267 #endif /* SYS_LIGHTWEIGHT_PROT */ 00268 00269 memp_free(type, mem); 00270 00271 #if SYS_LIGHTWEIGHT_PROT 00272 SYS_ARCH_UNPROTECT(old_level); 00273 #else /* SYS_LIGHTWEIGHT_PROT */ 00274 sys_sem_signal(mutex); 00275 #endif /* SYS_LIGHTWEIGHT_PROT */ 00276 00277 } |
Here is the call graph for this function:
|
Definition at line 141 of file memp.c. References MEM_ALIGN, MEM_ALIGN_SIZE, MEMP_MAX, memp_memory, memp_num, memp_sizes, memp_tab, mutex, memp::next, NULL, sys_sem_new(), u16_t, and u8_t.
00142 { 00143 struct memp *m, *memp; 00144 u16_t i, j; 00145 u16_t size; 00146 00147 #ifdef MEMP_STATS 00148 for(i = 0; i < MEMP_MAX; ++i) { 00149 lwip_stats.memp[i].used = lwip_stats.memp[i].max = 00150 lwip_stats.memp[i].err = 0; 00151 lwip_stats.memp[i].avail = memp_num[i]; 00152 } 00153 #endif /* MEMP_STATS */ 00154 00155 memp = (struct memp *)&memp_memory[0]; 00156 for(i = 0; i < MEMP_MAX; ++i) { 00157 size = MEM_ALIGN_SIZE(memp_sizes[i] + sizeof(struct memp)); 00158 if(memp_num[i] > 0) { 00159 memp_tab[i] = memp; 00160 m = memp; 00161 00162 for(j = 0; j < memp_num[i]; ++j) { 00163 m->next = (struct memp *)MEM_ALIGN((u8_t *)m + size); 00164 memp = m; 00165 m = m->next; 00166 } 00167 memp->next = NULL; 00168 memp = m; 00169 } else { 00170 memp_tab[i] = NULL; 00171 } 00172 } 00173 00174 #if !SYS_LIGHTWEIGHT_PROT 00175 mutex = sys_sem_new(1); 00176 #endif 00177 00178 00179 } |
Here is the call graph for this function:
|
Definition at line 182 of file memp.c. References DEBUGF, LWIP_ASSERT, MEM_ALIGN, MEMP_DEBUG, MEMP_MAX, memp_sizes, memp_tab, memp::next, NULL, u32_t, and u8_t. Referenced by memp_mallocp().
00183 { 00184 struct memp *memp; 00185 void *mem; 00186 00187 LWIP_ASSERT("memp_malloc: type < MEMP_MAX", type < MEMP_MAX); 00188 00189 memp = memp_tab[type]; 00190 00191 if(memp != NULL) { 00192 memp_tab[type] = memp->next; 00193 memp->next = NULL; 00194 #ifdef MEMP_STATS 00195 ++lwip_stats.memp[type].used; 00196 if(lwip_stats.memp[type].used > lwip_stats.memp[type].max) { 00197 lwip_stats.memp[type].max = lwip_stats.memp[type].used; 00198 } 00199 #endif /* MEMP_STATS */ 00200 LWIP_ASSERT("memp_malloc: memp properly aligned", 00201 ((u32_t)MEM_ALIGN((u8_t *)memp + sizeof(struct memp)) % MEM_ALIGNMENT) == 0); 00202 00203 mem = MEM_ALIGN((u8_t *)memp + sizeof(struct memp)); 00204 /* initialize memp memory with zeroes */ 00205 memset(mem, 0, memp_sizes[type]); 00206 return mem; 00207 } else { 00208 DEBUGF(MEMP_DEBUG | 2, ("memp_malloc: out of memory in pool %d\n", type)); 00209 #ifdef MEMP_STATS 00210 ++lwip_stats.memp[type].err; 00211 #endif /* MEMP_STATS */ 00212 return NULL; 00213 } 00214 } |
|
Definition at line 217 of file memp.c. References memp_malloc(), mutex, sys_sem_signal(), and sys_sem_wait(). Referenced by netbuf_new(), netconn_bind(), netconn_close(), netconn_connect(), netconn_delete(), netconn_disconnect(), netconn_listen(), netconn_new(), netconn_recv(), netconn_send(), netconn_write(), pbuf_alloc(), tcpip_apimsg(), tcpip_callback(), and tcpip_input().
00218 { 00219 void *mem; 00220 #if SYS_LIGHTWEIGHT_PROT 00221 SYS_ARCH_DECL_PROTECT(old_level); 00222 SYS_ARCH_PROTECT(old_level); 00223 #else /* SYS_LIGHTWEIGHT_PROT */ 00224 sys_sem_wait(mutex); 00225 #endif /* SYS_LIGHTWEIGHT_PROT */ 00226 00227 mem = memp_malloc(type); 00228 00229 #if SYS_LIGHTWEIGHT_PROT 00230 SYS_ARCH_UNPROTECT(old_level); 00231 #else /* SYS_LIGHTWEIGHT_PROT */ 00232 sys_sem_signal(mutex); 00233 #endif /* SYS_LIGHTWEIGHT_PROT */ 00234 return mem; 00235 } |
Here is the call graph for this function:
|
|