mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
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:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
@@ -215,18 +170,18 @@ dcoresize(void)
|
||||
char *
|
||||
strncasestr(const char *str1, const char *str2, size_t len)
|
||||
{
|
||||
while (*str1 && len--)
|
||||
{
|
||||
if (UPPER(*str1) == UPPER(*str2))
|
||||
while (*str1 && len--)
|
||||
{
|
||||
if (toupper(*str1) == toupper(*str2))
|
||||
{
|
||||
if (strncasecmp(str1,str2,strlen(str2)) == 0)
|
||||
{
|
||||
if (strncasecmp(str1,str2,strlen(str2)) == 0)
|
||||
{
|
||||
return (char *) str1;
|
||||
}
|
||||
return (char *) str1;
|
||||
}
|
||||
str1++;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
str1++;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Search for str2 in str1, ignore case.
|
||||
@@ -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 */
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -518,7 +518,7 @@ gnc_reconcile_list_reconciled_balance(GNCReconcileList *list)
|
||||
total += DxaccSplitGetValue(split);
|
||||
}
|
||||
|
||||
return DABS(total);
|
||||
return ABS(total);
|
||||
}
|
||||
|
||||
|
||||
@@ -677,8 +677,8 @@ 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,
|
||||
gnc_commodity_get_mnemonic(currency));
|
||||
strings[3] = DxaccPrintAmount(ABS(amount), flags,
|
||||
gnc_commodity_get_mnemonic(currency));
|
||||
|
||||
reconciled = g_hash_table_lookup(list->reconciled, split) != NULL;
|
||||
recn = reconciled ? YREC : recn;
|
||||
|
||||
@@ -223,12 +223,12 @@ recnRecalculateBalance(RecnWindow *recnData)
|
||||
(GNC_RECONCILE_LIST(recnData->credit));
|
||||
|
||||
/* Update the total debit and credit fields */
|
||||
amount = DxaccPrintAmount(DABS(debit), flags,
|
||||
gnc_commodity_get_mnemonic(currency));
|
||||
amount = DxaccPrintAmount(ABS(debit), flags,
|
||||
gnc_commodity_get_mnemonic(currency));
|
||||
gtk_label_set_text(GTK_LABEL(recnData->total_debit), amount);
|
||||
|
||||
amount = DxaccPrintAmount(credit, flags,
|
||||
gnc_commodity_get_mnemonic(currency));
|
||||
gnc_commodity_get_mnemonic(currency));
|
||||
|
||||
gtk_label_set_text(GTK_LABEL(recnData->total_credit), amount);
|
||||
|
||||
@@ -237,7 +237,7 @@ recnRecalculateBalance(RecnWindow *recnData)
|
||||
if (reverse_balance)
|
||||
reconciled = -reconciled;
|
||||
amount = DxaccPrintAmount(reconciled, flags,
|
||||
gnc_commodity_get_mnemonic(currency));
|
||||
gnc_commodity_get_mnemonic(currency));
|
||||
gnc_set_label_color(recnData->reconciled, reconciled);
|
||||
gtk_label_set_text(GTK_LABEL(recnData->reconciled), amount);
|
||||
if (reverse_balance)
|
||||
@@ -248,7 +248,7 @@ recnRecalculateBalance(RecnWindow *recnData)
|
||||
if (reverse_balance)
|
||||
diff = -diff;
|
||||
amount = DxaccPrintAmount(diff, flags,
|
||||
gnc_commodity_get_mnemonic(currency));
|
||||
gnc_commodity_get_mnemonic(currency));
|
||||
gnc_set_label_color(recnData->difference, diff);
|
||||
gtk_label_set_text(GTK_LABEL(recnData->difference), amount);
|
||||
if (reverse_balance)
|
||||
|
||||
Reference in New Issue
Block a user