Committer : entrope
CVSROOT : /cvsroot/undernet-ircu
Module : ircu2.10
Commit time: 2004-10-05 01:54:40 UTC
Modified files:
include/ircd_alloc.h ircd/ircd_alloc.c
Log message:
Doxyfy ircd_alloc.h and ircd_alloc.c.
---------------------- diff included ----------------------
Index: ircu2.10/include/ircd_alloc.h
diff -u ircu2.10/include/ircd_alloc.h:1.6 ircu2.10/include/ircd_alloc.h:1.7
--- ircu2.10/include/ircd_alloc.h:1.6 Sun May 9 18:32:52 2004
+++ ircu2.10/include/ircd_alloc.h Mon Oct 4 18:54:30 2004
@@ -1,7 +1,6 @@
/*
* IRC - Internet Relay Chat, include/ircd_alloc.h
* Copyright (C) 1999 Thomas Helvey <[EMAIL PROTECTED]>
- *
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -18,8 +17,10 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* Commentary by Bleep (Thomas Helvey)
- *
- * $Id: ircd_alloc.h,v 1.6 2004/05/10 01:32:52 entrope Exp $
+ */
+/** @file
+ * @brief IRC daemon memory allocation functions.
+ * @version $Id: ircd_alloc.h,v 1.7 2004/10/05 01:54:30 entrope Exp $
*/
#ifndef INCLUDED_ircd_alloc_h
#define INCLUDED_ircd_alloc_h
@@ -27,20 +28,25 @@
/*
* memory resource allocation and test functions
*/
+/** Type of handler for out-of-memory conditions. */
typedef void (*OutOfMemoryHandler)(void);
extern void set_nomem_handler(OutOfMemoryHandler handler);
/* The mappings for the My* functions... */
+/** Helper macro for standard allocations. */
#define MyMalloc(size) \
DoMalloc(size, "malloc", __FILE__, __LINE__)
+/** Helper macro for zero-initialized allocations. */
#define MyCalloc(nelem, size) \
DoMallocZero(size * nelem, "calloc", __FILE__, __LINE__)
+/** Helper macro for freeing memory. */
#define MyFree(p) \
if (p) \
DoFree(p, __FILE__, __LINE__)
+/** Helper macro for reallocating memory. */
#define MyRealloc(p, size) \
DoRealloc(p, size, __FILE__, __LINE__)
@@ -51,8 +57,7 @@
#define INCLUDED_stdlib_h
#endif
-extern OutOfMemoryHandler noMemHandler;
-
+/** Implementation macro for freeing memory. */
#define DoFree(x, file, line) do { free((x)); (x) = 0; } while(0)
extern void* DoMalloc(size_t len, const char*, const char*, int);
extern void* DoMallocZero(size_t len, const char*, const char*, int);
Index: ircu2.10/ircd/ircd_alloc.c
diff -u ircu2.10/ircd/ircd_alloc.c:1.7 ircu2.10/ircd/ircd_alloc.c:1.8
--- ircu2.10/ircd/ircd_alloc.c:1.7 Sun May 9 18:32:51 2004
+++ ircu2.10/ircd/ircd_alloc.c Mon Oct 4 18:54:30 2004
@@ -1,9 +1,9 @@
/************************************************************************
* IRC - Internet Relay Chat, ircd/ircd_alloc.c
* Copyright (C) 1999 Thomas Helvey (BleepSoft)
- *
+ *
* See file AUTHORS in IRC package for additional names of
- * the programmers.
+ * the programmers.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -18,8 +18,10 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: ircd_alloc.c,v 1.7 2004/05/10 01:32:51 entrope Exp $
+ */
+/** @file
+ * @brief IRC daemon memory allocation functions.
+ * @version $Id: ircd_alloc.c,v 1.8 2004/10/05 01:54:30 entrope Exp $
*/
#include "config.h"
@@ -32,10 +34,10 @@
static void nomem_handler(void);
-/* Those ugly globals... */
-OutOfMemoryHandler noMemHandler = nomem_handler;
-void *malloc_tmp;
+/** Variable holding out-of-memory callback. */
+static OutOfMemoryHandler noMemHandler = nomem_handler;
+/** Default handler for out-of-memory conditions. */
static void
nomem_handler(void)
{
@@ -47,12 +49,20 @@
#endif
}
+/** Set callback function for out-of-memory conditions. */
void
set_nomem_handler(OutOfMemoryHandler handler)
{
noMemHandler = handler;
}
+/** Allocate memory.
+ * @param[in] size Number of bytes to allocate.
+ * @param[in] x Type of allocation (ignored).
+ * @param[in] y Name of file doing allocation (ignored).
+ * @param[in] z Line number doing allocation (ignored).
+ * @return Newly allocated block of memory.
+ */
void* DoMalloc(size_t size, const char* x, const char* y, int z)
{
void* t = malloc(size);
@@ -61,6 +71,13 @@
return t;
}
+/** Allocate zero-initialized memory.
+ * @param[in] size Number of bytes to allocate.
+ * @param[in] x Type of allocation (ignored).
+ * @param[in] y Name of file doing allocation (ignored).
+ * @param[in] z Line number doing allocation (ignored).
+ * @return Newly allocated block of memory.
+ */
void* DoMallocZero(size_t size, const char* x, const char* y, int z)
{
void* t = malloc(size);
@@ -70,6 +87,12 @@
return t;
}
+/** Resize an allocated block of memory.
+ * @param[in] orig Original block to resize.
+ * @param[in] size Minimum size for new block.
+ * @param[in] file Name of file doing reallocation (ignored).
+ * @param[in] line Line number doing reallocation (ignored).
+ */
void* DoRealloc(void *orig, size_t size, const char *file, int line)
{
void* t = realloc(orig, size);
----------------------- End of diff -----------------------