Remove crufty macros and memory routines.

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@3104 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Dave Peticolas
2000-10-31 09:50:46 +00:00
parent 5974d8da52
commit 2b4cf35206
6 changed files with 27 additions and 90 deletions

View File

@@ -2903,7 +2903,7 @@ xaccSRGetEntryHandler (gpointer vcell_data, short _cell_type,
if ((amount > 0.0) && (cell_type == CRED_CELL))
return "";
amount = DABS (amount);
amount = ABS (amount);
return DxaccPrintAmount (amount, PRTSEP, NULL);
}

View File

@@ -34,6 +34,7 @@
* Copyright (c) 1999, 2000 Linas Vepstas
*/
#include <glib.h>
#include <limits.h>
#include <stdlib.h>
#include <strings.h>
@@ -73,7 +74,7 @@ Queue *
xaccMallocQueue (void)
{
Queue * ret;
ret = (Queue *) _malloc (sizeof (Queue));
ret = g_new(Queue, 1);
xaccInitQueue (ret);
return ret;
}
@@ -86,7 +87,7 @@ xaccInitQueue (Queue *q)
{
if (!q) return;
q->split_list = (Split **) malloc (INITIAL_LENGTH * sizeof (Split *));
q->split_list = (Split **) g_malloc (INITIAL_LENGTH * sizeof (Split *));
q->list_len = INITIAL_LENGTH;
q->head_split = -1;
q->tail_split = 0;
@@ -108,7 +109,7 @@ xaccFreeQueue (Queue *q)
{
if (!q) return;
if (q->split_list) _free (q->split_list);
if (q->split_list) g_free (q->split_list);
q->split_list = 0x0;
q->list_len = -1;
q->head_split = -1;
@@ -118,7 +119,7 @@ xaccFreeQueue (Queue *q)
q->head_price = 0.0;
q->tail_price = 0.0;
_free (q);
g_free (q);
}
/* ================================================== */
@@ -149,7 +150,7 @@ ExtendHead (Queue * q)
}
/* if we got to here, we need to malloc more memory. */
newlist = (Split **) malloc (2*(q->list_len)*sizeof (Split *));
newlist = (Split **) g_malloc (2*(q->list_len)*sizeof (Split *));
q->list_len *= 2;
len = q->head_split - q->tail_split + 1;

View File

@@ -163,51 +163,6 @@ gnc_set_auto_decimal_places( int places )
/********************************************************************\
\********************************************************************/
/********************************************************************\
* DEBUGGING MEMORY ALLOCATION STUFF *
\********************************************************************/
#if DEBUG_MEMORY
/* #if defined (__NetBSD__) || defined(__FreeBSD__) */
#ifndef HAVE_MALLOC_USABLE_SIZE
#define malloc_usable_size(ptr) 0
#endif
size_t core=0;
void
dfree( void *ptr )
{
core -= malloc_usable_size(ptr);
free(ptr);
}
void*
dmalloc( size_t size )
{
int i;
char *ptr;
ptr = (char *)malloc(size);
for( i=0; i<size; i++ )
ptr[i] = '.';
core += malloc_usable_size(ptr);
return (void *)ptr;
}
size_t
dcoresize(void)
{
return core;
}
#endif
/********************************************************************\
\********************************************************************/
#define UPPER(c) (((c) >= 'a' && (c) <= 'z') ? (c) + 'A' - 'a' : (c))
/* Search for str2 in first nchar chars of str1, ignore case..
* Return pointer to first match, or null.
*/
@@ -217,7 +172,7 @@ strncasestr(const char *str1, const char *str2, size_t len)
{
while (*str1 && len--)
{
if (UPPER(*str1) == UPPER(*str2))
if (toupper(*str1) == toupper(*str2))
{
if (strncasecmp(str1,str2,strlen(str2)) == 0)
{
@@ -567,7 +522,7 @@ PrintAmt(char *buf, double val, int prec,
/* print the absolute value */
if (val < 0.0)
val = DABS(val);
val = ABS(val);
/* print the value without separators */
util_fptostr(temp_buf, val, prec);
@@ -788,7 +743,7 @@ DxaccSPrintAmountGeneral (char * bufp, double val,
bufp = stpcpy(bufp, "(");
/* Now print the value */
bufp += PrintAmt(bufp, DABS(val), precision, flags & PRTSEP,
bufp += PrintAmt(bufp, ABS(val), precision, flags & PRTSEP,
!(flags & PRTNMN), min_trailing_zeros);
/* Now see if we print parentheses */

View File

@@ -107,27 +107,8 @@ void gnc_log (gncModuleType module, gncLogLevel log_level,
#define ERROR() fprintf(stderr,"%s: Line %d, error = %s\n", \
__FILE__, __LINE__, strerror(errno));
#if DEBUG_MEMORY
void *dmalloc( size_t size );
void dfree( void *ptr );
size_t dcoresize(void);
# define _malloc(x) dmalloc(x)
# define _free(x) dfree(x)
# define _coresize() dcoresize()
#else
# define _malloc(x) malloc(x)
# define _free(x) free(x)
# define _coresize() 0
#endif
/** COOL MACROS *****************************************************/
#ifndef ABS
#define ABS(x) ((x)>=0) ? (x) : (-1*(x))
#endif
#define DABS(x) ((x)>=0.0) ? (x) : (-1.0*(x))
#define DMAX(x,y) ((x)>(y)) ? (x) : (y)
#define isNum(x) (((x)-0x30) < 0) ? 0 : (((x)-0x30) > 9) ? 0 : 1
#define EPS (1.0e-6)
#define DEQEPS(x,y,eps) (((((x)+(eps))>(y)) ? 1 : 0) && ((((x)-(eps))<(y)) ? 1 : 0))
#define DEQ(x,y) DEQEPS(x,y,EPS)

View File

@@ -518,7 +518,7 @@ gnc_reconcile_list_reconciled_balance(GNCReconcileList *list)
total += DxaccSplitGetValue(split);
}
return DABS(total);
return ABS(total);
}
@@ -677,7 +677,7 @@ gnc_reconcile_list_fill(GNCReconcileList *list)
strings[0] = gnc_print_date(ts);
strings[1] = xaccTransGetNum(trans);
strings[2] = xaccTransGetDescription(trans);
strings[3] = DxaccPrintAmount(DABS(amount), flags,
strings[3] = DxaccPrintAmount(ABS(amount), flags,
gnc_commodity_get_mnemonic(currency));
reconciled = g_hash_table_lookup(list->reconciled, split) != NULL;

View File

@@ -223,7 +223,7 @@ recnRecalculateBalance(RecnWindow *recnData)
(GNC_RECONCILE_LIST(recnData->credit));
/* Update the total debit and credit fields */
amount = DxaccPrintAmount(DABS(debit), flags,
amount = DxaccPrintAmount(ABS(debit), flags,
gnc_commodity_get_mnemonic(currency));
gtk_label_set_text(GTK_LABEL(recnData->total_debit), amount);