"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/memory.c" between
tin-2.4.4.tar.xz and tin-2.4.5.tar.xz

About: TIN is a threaded NNTP and spool based UseNet newsreader.

memory.c  (tin-2.4.4.tar.xz):memory.c  (tin-2.4.5.tar.xz)
/* /*
* Project : tin - a Usenet reader * Project : tin - a Usenet reader
* Module : memory.c * Module : memory.c
* Author : I. Lea & R. Skrenta * Author : I. Lea & R. Skrenta
* Created : 1991-04-01 * Created : 1991-04-01
* Updated : 2018-07-02 * Updated : 2020-05-19
* Notes : * Notes :
* *
* Copyright (c) 1991-2020 Iain Lea <iain@bricbrac.de>, Rich Skrenta <skrenta@pb m.com> * Copyright (c) 1991-2021 Iain Lea <iain@bricbrac.de>, Rich Skrenta <skrenta@pb m.com>
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
* are met: * are met:
* *
* 1. Redistributions of source code must retain the above copyright notice, * 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer. * this list of conditions and the following disclaimer.
* *
* 2. Redistributions in binary form must reproduce the above copyright * 2. Redistributions in binary form must reproduce the above copyright
skipping to change at line 138 skipping to change at line 138
} }
void void
expand_art( expand_art(
void) void)
{ {
int i = max_art; int i = max_art;
max_art += max_art >> 1; /* increase by 50% */ max_art += max_art >> 1; /* increase by 50% */
arts = my_realloc(arts, sizeof(*arts) * max_art); arts = my_realloc(arts, sizeof(*arts) * max_art);
for (; i < max_art; i++) /* use memset() instead? */ /*
* memset(&arts[i].artnum, 0, (max_art - i - 1) * sizeof(*arts));
* seems to be not faster at all
*/
for (; i < max_art; i++)
arts[i].subject = arts[i].from = arts[i].xref = arts[i].path = ar ts[i].refs = arts[i].msgid = NULL; arts[i].subject = arts[i].from = arts[i].xref = arts[i].path = ar ts[i].refs = arts[i].msgid = NULL;
} }
void void
expand_active( expand_active(
void) void)
{ {
max_active += max_active >> 1; /* increase by 50% */ max_active += max_active >> 1; /* increase by 50% */
if (active == NULL) { if (active == NULL) {
active = my_malloc(sizeof(*active) * max_active); active = my_malloc(sizeof(*active) * max_active);
skipping to change at line 511 skipping to change at line 515
void * void *
my_malloc1( my_malloc1(
const char *file, const char *file,
int line, int line,
size_t size) size_t size)
{ {
void *p; void *p;
#ifdef DEBUG #ifdef DEBUG
debug_print_malloc(TRUE, file, line, size); if (debug & DEBUG_MEM)
debug_print_malloc(TRUE, file, line, size);
#endif /* DEBUG */ #endif /* DEBUG */
if ((p = malloc(size)) == NULL) { if ((p = malloc(size)) == NULL) {
error_message(2, txt_out_of_memory, tin_progname, (unsigned long) size, file, line); error_message(2, txt_out_of_memory, tin_progname, (unsigned long) size, file, line);
giveup(); giveup();
} }
return p; return p;
} }
/* /*
skipping to change at line 534 skipping to change at line 539
void * void *
my_calloc1( my_calloc1(
const char *file, const char *file,
int line, int line,
size_t nmemb, size_t nmemb,
size_t size) size_t size)
{ {
void *p; void *p;
#ifdef DEBUG #ifdef DEBUG
debug_print_malloc(TRUE, file, line, nmemb * size); if (debug & DEBUG_MEM)
debug_print_malloc(TRUE, file, line, nmemb * size);
#endif /* DEBUG */ #endif /* DEBUG */
if ((p = calloc(nmemb, size)) == NULL) { if ((p = calloc(nmemb, size)) == NULL) {
error_message(2, txt_out_of_memory, tin_progname, (unsigned long) (nmemb * size), file, line); error_message(2, txt_out_of_memory, tin_progname, (unsigned long) (nmemb * size), file, line);
giveup(); giveup();
} }
return p; return p;
} }
void * void *
my_realloc1( my_realloc1(
const char *file, const char *file,
int line, int line,
void *p, void *p,
size_t size) size_t size)
{ {
#ifdef DEBUG #ifdef DEBUG
debug_print_malloc(FALSE, file, line, size); if (debug & DEBUG_MEM)
debug_print_malloc(FALSE, file, line, size);
#endif /* DEBUG */ #endif /* DEBUG */
if (!size) { if (!size) {
if (p) if (p)
free(p); free(p);
return NULL; return NULL;
} }
if (p) { if (p) {
 End of changes. 6 change blocks. 
6 lines changed or deleted 13 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)