aboutsummaryrefslogtreecommitdiffstats
path: root/FICS/rmalloc.c
diff options
context:
space:
mode:
authorMarkus Uhlin <markus@nifty-networks.net>2023-12-20 02:16:43 +0100
committerMarkus Uhlin <markus@nifty-networks.net>2023-12-20 02:16:43 +0100
commitd0bd27f7309692314aa6ed54ee18405212ff11e6 (patch)
tree0f0e8bb39e401fe97a85c181179beb6623bc034d /FICS/rmalloc.c
parent0f48fbcf58394305e07a2c1aab8d420fe54b7b11 (diff)
Reformatted functions
Diffstat (limited to 'FICS/rmalloc.c')
-rw-r--r--FICS/rmalloc.c82
1 files changed, 45 insertions, 37 deletions
diff --git a/FICS/rmalloc.c b/FICS/rmalloc.c
index 9eb0dbc..97d8622 100644
--- a/FICS/rmalloc.c
+++ b/FICS/rmalloc.c
@@ -31,57 +31,65 @@ PUBLIC unsigned int allocated_size = 0;
PUBLIC unsigned int malloc_count = 0;
PUBLIC unsigned int free_count = 0;
-PUBLIC void *rmalloc(int byteSize)
+PUBLIC void *
+rmalloc(int byteSize)
{
- void *newptr;
+ void *newptr;
+
#ifdef HASMALLOCSIZE
- allocated_size += byteSize;
+ allocated_size += byteSize;
#endif
- malloc_count++;
- newptr = malloc(byteSize);
- if (newptr == NULL) {
- fprintf(stderr, "Out of memory in malloc!\n");
- abort();
- }
- return newptr;
+
+ malloc_count++;
+
+ if ((newptr = malloc(byteSize)) == NULL) {
+ fprintf(stderr, "Out of memory in malloc!\n");
+ abort();
+ }
+
+ return newptr;
}
-PUBLIC void *rrealloc(void *ptr, int byteSize)
+PUBLIC void *
+rrealloc(void *ptr, int byteSize)
{
#ifdef HASMALLOCSIZE
- allocated_size += (byteSize - malloc_size(ptr));
+ allocated_size += (byteSize - malloc_size(ptr));
#endif
- if (ptr == NULL) { /* Sparky 3/16/95 */
- fprintf(stderr, "Hoser! Null ptr passed to rrealloc!!\n");
- return NULL;
- } else {
- void *newptr = realloc(ptr, byteSize);
- if (newptr == NULL) {
- fprintf(stderr, "Out of memory in rrealloc!\n");
- abort();
- }
- return newptr;
- }
+
+ if (ptr == NULL) {
+ fprintf(stderr, "Hoser! Null ptr passed to rrealloc!\n");
+ return NULL;
+ } else {
+ void *newptr;
+
+ if ((newptr = realloc(ptr, byteSize)) == NULL) {
+ fprintf(stderr, "Out of memory in rrealloc!\n");
+ abort();
+ }
+
+ return newptr;
+ }
}
-PUBLIC void rfree(void *ptr)
+PUBLIC void
+rfree(void *ptr)
{
#ifdef HASMALLOCSIZE
- allocated_size = allocated_size - malloc_size(ptr);
+ allocated_size = (allocated_size - malloc_size(ptr));
#endif
- if (ptr == NULL) { /* Sparky 3/16/95 */
- fprintf(stderr, "Hoser! Null ptr passed to rfree!!\n");
- } else {
- free_count++;
- free(ptr);
- }
+
+ if (ptr == NULL) {
+ fprintf(stderr, "Hoser! Null ptr passed to rfree!\n");
+ } else {
+ free_count++;
+ free(ptr);
+ }
}
-PUBLIC void strfree (char *string)
+PUBLIC void
+strfree(char *string)
{
- /* This routine is often called on strings that are either
- a rmalloc'd value or NULL. So it's not an error to see
- a NULL here. --mann
- */
- if (string != NULL) rfree (string);
+ if (string != NULL)
+ rfree(string);
}