143 |
} |
} |
144 |
|
|
145 |
/* Ok, allocate a structure; we'll realloc later to trim memory */ |
/* Ok, allocate a structure; we'll realloc later to trim memory */ |
146 |
cache = MyMalloc(sizeof(struct MotdCache) + (MOTD_LINESIZE * (MOTD_MAXLINES - 1))); |
cache = MyMalloc(sizeof(struct MotdCache) + (MOTD_LINESIZE * MOTD_MAXLINES)); |
147 |
cache->ref = 1; |
cache->ref = 1; |
148 |
cache->path = xstrdup(motd->path); |
cache->path = xstrdup(motd->path); |
149 |
cache->maxcount = motd->maxcount; |
cache->maxcount = motd->maxcount; |
163 |
|
|
164 |
/* trim memory usage a little */ |
/* trim memory usage a little */ |
165 |
motd->cache = MyMalloc(sizeof(struct MotdCache) + |
motd->cache = MyMalloc(sizeof(struct MotdCache) + |
166 |
(MOTD_LINESIZE * (cache->count - 1))); |
(MOTD_LINESIZE * cache->count)); |
167 |
memcpy(motd->cache, cache, sizeof(struct MotdCache) + |
memcpy(motd->cache, cache, sizeof(struct MotdCache) + |
168 |
(MOTD_LINESIZE * (cache->count - 1))); |
(MOTD_LINESIZE * cache->count)); |
169 |
MyFree(cache); |
MyFree(cache); |
170 |
|
|
171 |
/* now link it in... */ |
/* now link it in... */ |