/[lwip]/lwip/src/core/memp.c
ViewVC logotype

Diff of /lwip/src/core/memp.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.15 by likewise, Thu May 1 13:24:01 2003 UTC revision 1.16 by likewise, Mon Jun 9 21:14:47 2003 UTC
# Line 79  static const u16_t memp_num[MEMP_MAX] = Line 79  static const u16_t memp_num[MEMP_MAX] =
79  };  };
80    
81  static u8_t memp_memory[(MEMP_NUM_PBUF *  static u8_t memp_memory[(MEMP_NUM_PBUF *
82                           MEM_ALIGN_SIZE(sizeof(struct pbuf) +         MEM_ALIGN_SIZE(sizeof(struct pbuf) +
83                                          sizeof(struct memp)) +            sizeof(struct memp)) +
84                          MEMP_NUM_UDP_PCB *        MEMP_NUM_UDP_PCB *
85                           MEM_ALIGN_SIZE(sizeof(struct udp_pcb) +         MEM_ALIGN_SIZE(sizeof(struct udp_pcb) +
86                                          sizeof(struct memp)) +            sizeof(struct memp)) +
87                          MEMP_NUM_TCP_PCB *        MEMP_NUM_TCP_PCB *
88                           MEM_ALIGN_SIZE(sizeof(struct tcp_pcb) +         MEM_ALIGN_SIZE(sizeof(struct tcp_pcb) +
89                                          sizeof(struct memp)) +            sizeof(struct memp)) +
90                          MEMP_NUM_TCP_PCB_LISTEN *        MEMP_NUM_TCP_PCB_LISTEN *
91                           MEM_ALIGN_SIZE(sizeof(struct tcp_pcb_listen) +         MEM_ALIGN_SIZE(sizeof(struct tcp_pcb_listen) +
92                                          sizeof(struct memp)) +            sizeof(struct memp)) +
93                          MEMP_NUM_TCP_SEG *        MEMP_NUM_TCP_SEG *
94                           MEM_ALIGN_SIZE(sizeof(struct tcp_seg) +         MEM_ALIGN_SIZE(sizeof(struct tcp_seg) +
95                                          sizeof(struct memp)) +            sizeof(struct memp)) +
96                          MEMP_NUM_NETBUF *        MEMP_NUM_NETBUF *
97                           MEM_ALIGN_SIZE(sizeof(struct netbuf) +         MEM_ALIGN_SIZE(sizeof(struct netbuf) +
98                                          sizeof(struct memp)) +            sizeof(struct memp)) +
99                          MEMP_NUM_NETCONN *        MEMP_NUM_NETCONN *
100                           MEM_ALIGN_SIZE(sizeof(struct netconn) +         MEM_ALIGN_SIZE(sizeof(struct netconn) +
101                                          sizeof(struct memp)) +            sizeof(struct memp)) +
102                          MEMP_NUM_API_MSG *        MEMP_NUM_API_MSG *
103                           MEM_ALIGN_SIZE(sizeof(struct api_msg) +         MEM_ALIGN_SIZE(sizeof(struct api_msg) +
104                                          sizeof(struct memp)) +            sizeof(struct memp)) +
105                          MEMP_NUM_TCPIP_MSG *        MEMP_NUM_TCPIP_MSG *
106                           MEM_ALIGN_SIZE(sizeof(struct tcpip_msg) +         MEM_ALIGN_SIZE(sizeof(struct tcpip_msg) +
107                                          sizeof(struct memp)) +            sizeof(struct memp)) +
108                          MEMP_NUM_SYS_TIMEOUT *        MEMP_NUM_SYS_TIMEOUT *
109                           MEM_ALIGN_SIZE(sizeof(struct sys_timeout) +         MEM_ALIGN_SIZE(sizeof(struct sys_timeout) +
110                                          sizeof(struct memp)))];            sizeof(struct memp)))];
111    
112  /*-----------------------------------------------------------------------------------*/  /*-----------------------------------------------------------------------------------*/
113  #if !SYS_LIGHTWEIGHT_PROT  #if !SYS_LIGHTWEIGHT_PROT
# Line 125  memp_sanity(void) Line 125  memp_sanity(void)
125      for(m = memp_tab[i]; m != NULL; m = m->next) {      for(m = memp_tab[i]; m != NULL; m = m->next) {
126        c = 1;        c = 1;
127        for(n = memp_tab[i]; n != NULL; n = n->next) {        for(n = memp_tab[i]; n != NULL; n = n->next) {
128          if (n == m) {           if (n == m) {
129                  --c;            --c;
130          }          }
131                if (c < 0) return 0; /* LW was: abort(); */          if (c < 0) return 0; /* LW was: abort(); */
132        }        }
133      }      }
134    }    }
# Line 159  memp_init(void) Line 159  memp_init(void)
159        m = memp;        m = memp;
160                
161        for(j = 0; j < memp_num[i]; ++j) {        for(j = 0; j < memp_num[i]; ++j) {
162          m->next = (struct memp *)MEM_ALIGN((u8_t *)m + size);    m->next = (struct memp *)MEM_ALIGN((u8_t *)m + size);
163          memp = m;    memp = m;
164          m = m->next;    m = m->next;
165        }        }
166        memp->next = NULL;        memp->next = NULL;
167        memp = m;        memp = m;
# Line 197  memp_malloc(memp_t type) Line 197  memp_malloc(memp_t type)
197      }      }
198  #endif /* MEMP_STATS */  #endif /* MEMP_STATS */
199      LWIP_ASSERT("memp_malloc: memp properly aligned",      LWIP_ASSERT("memp_malloc: memp properly aligned",
200             ((u32_t)MEM_ALIGN((u8_t *)memp + sizeof(struct memp)) % MEM_ALIGNMENT) == 0);       ((u32_t)MEM_ALIGN((u8_t *)memp + sizeof(struct memp)) % MEM_ALIGNMENT) == 0);
201    
202      mem = MEM_ALIGN((u8_t *)memp + sizeof(struct memp));      mem = MEM_ALIGN((u8_t *)memp + sizeof(struct memp));
203      /* initialize memp memory with zeroes */      /* initialize memp memory with zeroes */
204      memset(mem, 0, memp_sizes[type]);        memset(mem, 0, memp_sizes[type]);  
205      return mem;      return mem;
206    } else {    } else {
207      DEBUGF(MEMP_DEBUG | 2, ("memp_malloc: out of memory in pool %d\n", type));      DEBUGF(MEMP_DEBUG | 2, ("memp_malloc: out of memory in pool %d\n", type));

Legend:
Removed from v.1.15  
changed lines
  Added in v.1.16

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26