elog(ERROR,"Second must be limited to values 0 through < 60 in '%s'",
str);
- time = PALLOCTYPE(TimeADT);
+ time = palloc(sizeof(TimeADT));
*time = ((((tm->tm_hour*60)+tm->tm_min)*60));
sprintf(buf, "%02d:%02d:%02d", tm->tm_hour, tm->tm_min, tm->tm_sec);
}
- result = PALLOC(strlen(buf)+1);
+ result = palloc(strlen(buf)+1);
strcpy( result, buf);
TimeADT *
hhmm(TimeADT *time)
{
- TimeADT *result = PALLOCTYPE(TimeADT);
+ TimeADT *result = palloc(sizeof(TimeADT));
*result = (((int) *time) / 60 * 60);
TimeADT *
time_difference(TimeADT *time1, TimeADT *time2)
{
- TimeADT *time = PALLOCTYPE(TimeADT);
+ TimeADT *time = palloc(sizeof(TimeADT));
*time = (*time1 - *time2);
return(time);
TimeADT *
currenttime()
{
- TimeADT *result = PALLOCTYPE(TimeADT);
+ TimeADT *result = palloc(sizeof(TimeADT));
struct tm *tm;
time_t current_time;
#define MAXINT8LEN 25
-#define USE_LOCAL_CODE 1
-
#if defined(__alpha) || defined(__GNUC__)
#define HAVE_64BIT_INTS 1
#endif
float64 i8tod(int64 * val);
int64 *dtoi8(float64 val);
-#if USE_LOCAL_CODE
-
-#ifndef PALLOC
-#define PALLOC(p) palloc(p)
-#endif
-
-#ifndef PALLOCTYPE
-#define PALLOCTYPE(p) palloc(sizeof(p))
-#endif
-
-#endif
-
/***********************************************************************
**
** Routines for 64-bit integers.
int64 *
int8in(char *str)
{
- int64 *result = PALLOCTYPE(int64);
+ int64 *result = palloc(sizeof(int64));
#if HAVE_64BIT_INTS
if (!PointerIsValid(str))
if ((len = snprintf(buf, MAXINT8LEN, INT64_FORMAT, *val)) < 0)
elog(ERROR, "Unable to format int8", NULL);
- result = PALLOC(len + 1);
+ result = palloc(len + 1);
strcpy(result, buf);
int64 *
int8um(int64 * val)
{
- int64 *result = PALLOCTYPE(int64);
+ int64 *result = palloc(sizeof(int64));
if (!PointerIsValid(val))
return NULL;
int64 *
int8pl(int64 * val1, int64 * val2)
{
- int64 *result = PALLOCTYPE(int64);
+ int64 *result = palloc(sizeof(int64));
if ((!PointerIsValid(val1)) || (!PointerIsValid(val2)))
return NULL;
int64 *
int8mi(int64 * val1, int64 * val2)
{
- int64 *result = PALLOCTYPE(int64);
+ int64 *result = palloc(sizeof(int64));
if ((!PointerIsValid(val1)) || (!PointerIsValid(val2)))
return NULL;
int64 *
int8mul(int64 * val1, int64 * val2)
{
- int64 *result = PALLOCTYPE(int64);
+ int64 *result = palloc(sizeof(int64));
if ((!PointerIsValid(val1)) || (!PointerIsValid(val2)))
return NULL;
int64 *
int8div(int64 * val1, int64 * val2)
{
- int64 *result = PALLOCTYPE(int64);
+ int64 *result = palloc(sizeof(int64));
if ((!PointerIsValid(val1)) || (!PointerIsValid(val2)))
return NULL;
int64 *
int48(int32 val)
{
- int64 *result = PALLOCTYPE(int64);
+ int64 *result = palloc(sizeof(int64));
*result = val;
{
int64 *result;
- if (!PointerIsValid(result = PALLOCTYPE(int64)))
+ if (!PointerIsValid(result = palloc(sizeof(int64))))
elog(ERROR, "Memory allocation failed, can't convert int8 to int2", NULL);
*result = val;
float64
i8tod(int64 * val)
{
- float64 result = PALLOCTYPE(float64data);
+ float64 result = palloc(sizeof(float64data));
*result = *val;
int64 *
dtoi8(float64 val)
{
- int64 *result = PALLOCTYPE(int64);
+ int64 *result = palloc(sizeof(int64));
if ((*val < (-pow(2, 64) + 1)) || (*val > (pow(2, 64) - 1)))
elog(ERROR, "Floating point conversion to int64 is out of range", NULL);
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtproc.c,v 1.13 1998/01/05 03:29:59 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtproc.c,v 1.14 1998/01/07 18:46:15 momjian Exp $
*
*-------------------------------------------------------------------------
*/
{
POLYGON *p;
- p = (POLYGON *) PALLOCTYPE(POLYGON);
+ p = (POLYGON *) palloc(sizeof(POLYGON));
if (!PointerIsValid(p))
elog(ABORT, "Cannot allocate polygon for union");
{
POLYGON *p;
- p = (POLYGON *) PALLOCTYPE(POLYGON);
+ p = (POLYGON *) palloc(sizeof(POLYGON));
if (!PointerIsValid(p))
elog(ABORT, "Cannot allocate polygon for intersection");
* Routines for handling of 'SET var TO',
* 'SHOW var' and 'RESET var' statements.
*
- * $Id: variable.c,v 1.1 1998/01/05 18:42:50 momjian Exp $
+ * $Id: variable.c,v 1.2 1998/01/07 18:46:26 momjian Exp $
*
*/
len++;
}
- *tok = (char *) PALLOC(len + 1);
+ *tok = (char *) palloc(len + 1);
StrNCpy(*tok, start, len+1);
/* skip white spaces */
len++;
}
- *val = (char *) PALLOC(len + 1);
+ *val = (char *) palloc(len + 1);
StrNCpy(*val, start, len+1);
/* skip white spaces */
geqo_rels = pg_atoi(val, sizeof(int32), '\0');
if (geqo_rels <= 1)
elog(ERROR, "Bad value for # of relations (%s)", val);
- PFREE(val);
+ pfree(val);
}
_use_geqo_ = true;
_use_geqo_rels_ = geqo_rels;
else
elog(ERROR, "Bad value for GEQO (%s)", value);
- PFREE(tok);
+ pfree(tok);
return TRUE;
}
{
elog(ERROR, "Bad value for date style (%s)", tok);
}
- PFREE(tok);
+ pfree(tok);
}
if (dcnt > 1 || ecnt > 1)
elog(ERROR, "Unable to set TZ environment variable to %s", tok);
tzset();
- PFREE(tok);
+ pfree(tok);
}
return TRUE;
* workings can be found in the book "Software Solutions in C" by
* Dale Schumacher, Academic Press, ISBN: 0-12-632360-7.
*
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/cash.c,v 1.20 1998/01/05 16:39:45 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/cash.c,v 1.21 1998/01/07 18:46:34 momjian Exp $
*/
#include <stdio.h>
if (*s != '\0')
elog(ERROR, "Bad money external representation %s", str);
- if (!PointerIsValid(result = PALLOCTYPE(Cash)))
+ if (!PointerIsValid(result = palloc(sizeof(Cash))))
elog(ERROR, "Memory allocation failed, can't input cash '%s'", str);
*result = (value * sgn);
/* see if we need to signify negative amount */
if (minus)
{
- if (!PointerIsValid(result = PALLOC(CASH_BUFSZ + 2 - count + strlen(nsymbol))))
+ if (!PointerIsValid(result = palloc(CASH_BUFSZ + 2 - count + strlen(nsymbol))))
elog(ERROR, "Memory allocation failed, can't output cash", NULL);
/* Position code of 0 means use parens */
}
else
{
- if (!PointerIsValid(result = PALLOC(CASH_BUFSZ + 2 - count)))
+ if (!PointerIsValid(result = palloc(CASH_BUFSZ + 2 - count)))
elog(ERROR, "Memory allocation failed, can't output cash", NULL);
strcpy(result, buf + count);
if (!PointerIsValid(c1) || !PointerIsValid(c2))
return (NULL);
- if (!PointerIsValid(result = PALLOCTYPE(Cash)))
+ if (!PointerIsValid(result = palloc(sizeof(Cash))))
elog(ERROR, "Memory allocation failed, can't add cash", NULL);
*result = (*c1 + *c2);
if (!PointerIsValid(c1) || !PointerIsValid(c2))
return (NULL);
- if (!PointerIsValid(result = PALLOCTYPE(Cash)))
+ if (!PointerIsValid(result = palloc(sizeof(Cash))))
elog(ERROR, "Memory allocation failed, can't subtract cash", NULL);
*result = (*c1 - *c2);
if (!PointerIsValid(f) || !PointerIsValid(c))
return (NULL);
- if (!PointerIsValid(result = PALLOCTYPE(Cash)))
+ if (!PointerIsValid(result = palloc(sizeof(Cash))))
elog(ERROR, "Memory allocation failed, can't multiply cash", NULL);
*result = ((*f) * (*c));
if (!PointerIsValid(f) || !PointerIsValid(c))
return (NULL);
- if (!PointerIsValid(result = PALLOCTYPE(Cash)))
+ if (!PointerIsValid(result = palloc(sizeof(Cash))))
elog(ERROR, "Memory allocation failed, can't divide cash", NULL);
if (*f == 0.0)
if (!PointerIsValid(f) || !PointerIsValid(c))
return (NULL);
- if (!PointerIsValid(result = PALLOCTYPE(Cash)))
+ if (!PointerIsValid(result = palloc(sizeof(Cash))))
elog(ERROR, "Memory allocation failed, can't multiply cash", NULL);
*result = ((*f) * (*c));
if (!PointerIsValid(f) || !PointerIsValid(c))
return (NULL);
- if (!PointerIsValid(result = PALLOCTYPE(Cash)))
+ if (!PointerIsValid(result = palloc(sizeof(Cash))))
elog(ERROR, "Memory allocation failed, can't divide cash", NULL);
if (*f == 0.0)
if (!PointerIsValid(c))
return (NULL);
- if (!PointerIsValid(result = PALLOCTYPE(Cash)))
+ if (!PointerIsValid(result = palloc(sizeof(Cash))))
elog(ERROR, "Memory allocation failed, can't multiply cash", NULL);
*result = ((i) * (*c));
if (!PointerIsValid(c))
return (NULL);
- if (!PointerIsValid(result = PALLOCTYPE(Cash)))
+ if (!PointerIsValid(result = palloc(sizeof(Cash))))
elog(ERROR, "Memory allocation failed, can't divide cash", NULL);
if (i == 0)
if (!PointerIsValid(c))
return (NULL);
- if (!PointerIsValid(result = PALLOCTYPE(Cash)))
+ if (!PointerIsValid(result = palloc(sizeof(Cash))))
elog(ERROR, "Memory allocation failed, can't multiply cash", NULL);
*result = ((s) * (*c));
if (!PointerIsValid(c))
return (NULL);
- if (!PointerIsValid(result = PALLOCTYPE(Cash)))
+ if (!PointerIsValid(result = palloc(sizeof(Cash))))
elog(ERROR, "Memory allocation failed, can't divide cash", NULL);
if (s == 0)
if (!PointerIsValid(c1) || !PointerIsValid(c2))
return (NULL);
- if (!PointerIsValid(result = PALLOCTYPE(Cash)))
+ if (!PointerIsValid(result = palloc(sizeof(Cash))))
elog(ERROR, "Memory allocation failed, can't return larger cash", NULL);
*result = ((*c1 > *c2) ? *c1 : *c2);
if (!PointerIsValid(c1) || !PointerIsValid(c2))
return (NULL);
- if (!PointerIsValid(result = PALLOCTYPE(Cash)))
+ if (!PointerIsValid(result = palloc(sizeof(Cash))))
elog(ERROR, "Memory allocation failed, can't return smaller cash", NULL);
*result = ((*c1 < *c2) ? *c1 : *c2);
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/date.c,v 1.21 1998/01/05 16:39:48 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/date.c,v 1.22 1998/01/07 18:46:37 momjian Exp $
*
* NOTES
* This code is actually (almost) unused.
EncodeTimeSpan(tm, 0, DateStyle, buf);
}
- result = PALLOC(strlen(buf) + 1);
+ result = palloc(strlen(buf) + 1);
strcpy(result, buf);
return (result);
int year,
month;
- if (!PointerIsValid(result = PALLOCTYPE(TimeSpan)))
+ if (!PointerIsValid(result = palloc(sizeof(TimeSpan))))
elog(ERROR, "Memory allocation failed, can't convert reltime to timespan", NULL);
switch (reltime)
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/datetime.c,v 1.20 1998/01/05 16:39:50 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/datetime.c,v 1.21 1998/01/07 18:46:41 momjian Exp $
*
*-------------------------------------------------------------------------
*/
EncodeDateOnly(tm, DateStyle, buf);
- result = PALLOC(strlen(buf) + 1);
+ result = palloc(strlen(buf) + 1);
strcpy(result, buf);
double fsec = 0;
char *tzn;
- result = PALLOCTYPE(DateTime);
+ result = palloc(sizeof(DateTime));
if (date2tm(dateVal, &tz, tm, &fsec, &tzn) != 0)
elog(ERROR, "Unable to convert date to datetime", NULL);
if ((tm->tm_sec < 0) || ((tm->tm_sec + fsec) >= 60))
elog(ERROR, "Second must be limited to values 0 through < 60 in '%s'", str);
- time = PALLOCTYPE(TimeADT);
+ time = palloc(sizeof(TimeADT));
*time = ((((tm->tm_hour * 60) + tm->tm_min) * 60) + tm->tm_sec + fsec);
EncodeTimeOnly(tm, fsec, DateStyle, buf);
- result = PALLOC(strlen(buf) + 1);
+ result = palloc(strlen(buf) + 1);
strcpy(result, buf);
elog(ERROR, "Unable to convert datetime to date", NULL);
}
- result = PALLOCTYPE(TimeADT);
+ result = palloc(sizeof(TimeADT));
*result = ((((tm->tm_hour * 60) + tm->tm_min) * 60) + tm->tm_sec + fsec);
if (!PointerIsValid(time))
{
- result = PALLOCTYPE(DateTime);
+ result = palloc(sizeof(DateTime));
DATETIME_INVALID(*result);
} else {
result = date_datetime(date);
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/dt.c,v 1.49 1998/01/05 16:39:55 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/dt.c,v 1.50 1998/01/07 18:46:45 momjian Exp $
*
*-------------------------------------------------------------------------
*/
|| (DecodeDateTime(field, ftype, nf, &dtype, tm, &fsec, &tz) != 0))
elog(ERROR, "Bad datetime external representation '%s'", str);
- result = PALLOCTYPE(DateTime);
+ result = palloc(sizeof(DateTime));
switch (dtype)
{
EncodeSpecialDateTime(DT_INVALID, buf);
}
- result = PALLOC(strlen(buf) + 1);
+ result = palloc(strlen(buf) + 1);
strcpy(result, buf);
|| (DecodeDateDelta(field, ftype, nf, &dtype, tm, &fsec) != 0))
elog(ERROR, "Bad timespan external representation '%s'", str);
- span = PALLOCTYPE(TimeSpan);
+ span = palloc(sizeof(TimeSpan));
switch (dtype)
{
if (EncodeTimeSpan(tm, fsec, DateStyle, buf) != 0)
elog(ERROR, "Unable to format timespan", NULL);
- result = PALLOC(strlen(buf) + 1);
+ result = palloc(strlen(buf) + 1);
strcpy(result, buf);
return (result);
dt1 = *datetime1;
dt2 = *datetime2;
- result = PALLOCTYPE(DateTime);
+ result = palloc(sizeof(DateTime));
if (DATETIME_IS_RELATIVE(dt1))
dt1 = SetDateTime(dt1);
dt1 = *datetime1;
dt2 = *datetime2;
- result = PALLOCTYPE(DateTime);
+ result = palloc(sizeof(DateTime));
if (DATETIME_IS_RELATIVE(dt1))
dt1 = SetDateTime(dt1);
dt1 = *datetime1;
dt2 = *datetime2;
- result = PALLOCTYPE(TimeSpan);
+ result = palloc(sizeof(TimeSpan));
if (DATETIME_IS_RELATIVE(dt1))
dt1 = SetDateTime(dt1);
if ((!PointerIsValid(datetime)) || (!PointerIsValid(span)))
return NULL;
- result = PALLOCTYPE(DateTime);
+ result = palloc(sizeof(DateTime));
#ifdef DATEDEBUG
printf("datetime_pl_span- add %f to %d %f\n", *datetime, span->month, span->time);
if (!PointerIsValid(timespan))
return NULL;
- result = PALLOCTYPE(TimeSpan);
+ result = palloc(sizeof(TimeSpan));
result->time = -(timespan->time);
result->month = -(timespan->month);
if (!PointerIsValid(timespan1) || !PointerIsValid(timespan2))
return NULL;
- result = PALLOCTYPE(TimeSpan);
+ result = palloc(sizeof(TimeSpan));
if (TIMESPAN_IS_INVALID(*timespan1))
{
if (!PointerIsValid(timespan1) || !PointerIsValid(timespan2))
return NULL;
- result = PALLOCTYPE(TimeSpan);
+ result = palloc(sizeof(TimeSpan));
if (TIMESPAN_IS_INVALID(*timespan1))
{
if ((!PointerIsValid(span1)) || (!PointerIsValid(span2)))
return NULL;
- result = PALLOCTYPE(TimeSpan);
+ result = palloc(sizeof(TimeSpan));
result->month = (span1->month + span2->month);
result->time = JROUND(span1->time + span2->time);
if ((!PointerIsValid(span1)) || (!PointerIsValid(span2)))
return NULL;
- result = PALLOCTYPE(TimeSpan);
+ result = palloc(sizeof(TimeSpan));
result->month = (span1->month - span2->month);
result->time = JROUND(span1->time - span2->time);
if ((!PointerIsValid(span1)) || (!PointerIsValid(arg2)))
return NULL;
- if (!PointerIsValid(result = PALLOCTYPE(TimeSpan)))
+ if (!PointerIsValid(result = palloc(sizeof(TimeSpan))))
elog(ERROR, "Memory allocation failed, can't subtract timespans", NULL);
if (*arg2 == 0.0)
if (!PointerIsValid(datetime1) || !PointerIsValid(datetime2))
return NULL;
- result = PALLOCTYPE(TimeSpan);
+ result = palloc(sizeof(TimeSpan));
dt1 = *datetime1;
dt2 = *datetime2;
len = (strlen(str) + VARHDRSZ);
- result = PALLOC(len);
+ result = palloc(len);
VARSIZE(result) = len;
memmove(VARDATA(result), str, (len - VARHDRSZ));
- PFREE(str);
+ pfree(str);
return (result);
} /* datetime_text() */
len = (strlen(str) + VARHDRSZ);
- result = PALLOC(len);
+ result = palloc(len);
VARSIZE(result) = len;
memmove(VARDATA(result), str, (len - VARHDRSZ));
- PFREE(str);
+ pfree(str);
return (result);
} /* timespan_text() */
if ((!PointerIsValid(units)) || (!PointerIsValid(datetime)))
return NULL;
- result = PALLOCTYPE(DateTime);
+ result = palloc(sizeof(DateTime));
up = VARDATA(units);
lp = lowunits;
if ((!PointerIsValid(units)) || (!PointerIsValid(timespan)))
return NULL;
- result = PALLOCTYPE(TimeSpan);
+ result = palloc(sizeof(TimeSpan));
up = VARDATA(units);
lp = lowunits;
if ((!PointerIsValid(units)) || (!PointerIsValid(datetime)))
return NULL;
- result = PALLOCTYPE(float64data);
+ result = palloc(sizeof(float64data));
up = VARDATA(units);
lp = lowunits;
if ((!PointerIsValid(units)) || (!PointerIsValid(timespan)))
return NULL;
- result = PALLOCTYPE(float64data);
+ result = palloc(sizeof(float64data));
up = VARDATA(units);
lp = lowunits;
len = (strlen(buf) + VARHDRSZ);
- result = PALLOC(len);
+ result = palloc(len);
VARSIZE(result) = len;
memmove(VARDATA(result), buf, (len - VARHDRSZ));
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/geo_ops.c,v 1.28 1998/01/05 16:40:02 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/geo_ops.c,v 1.29 1998/01/07 18:46:47 momjian Exp $
*
*-------------------------------------------------------------------------
*/
static char *
path_encode(bool closed, int npts, Point *pt)
{
- char *result = PALLOC(npts * (P_MAXLEN + 3) + 2);
+ char *result = palloc(npts * (P_MAXLEN + 3) + 2);
char *cp;
int i;
BOX *
box_in(char *str)
{
- BOX *box = PALLOCTYPE(BOX);
+ BOX *box = palloc(sizeof(BOX));
int isopen;
char *s;
static BOX *
box_construct(double x1, double x2, double y1, double y2)
{
- BOX *result = PALLOCTYPE(BOX);
+ BOX *result = palloc(sizeof(BOX));
return (box_fill(result, x1, x2, y1, y2));
}
static BOX *
box_copy(BOX *box)
{
- BOX *result = PALLOCTYPE(BOX);
+ BOX *result = palloc(sizeof(BOX));
memmove((char *) result, (char *) box, sizeof(BOX));
double *
box_area(BOX *box)
{
- double *result = PALLOCTYPE(double);
+ double *result = palloc(sizeof(double));
*result = box_wd(box) * box_ht(box);
double *
box_width(BOX *box)
{
- double *result = PALLOCTYPE(double);
+ double *result = palloc(sizeof(double));
*result = box->high.x - box->low.x;
double *
box_height(BOX *box)
{
- double *result = PALLOCTYPE(double);
+ double *result = palloc(sizeof(double));
*result = box->high.y - box->low.y;
double *
box_distance(BOX *box1, BOX *box2)
{
- double *result = PALLOCTYPE(double);
+ double *result = palloc(sizeof(double));
Point *a,
*b;
b = box_center(box2);
*result = HYPOT(a->x - b->x, a->y - b->y);
- PFREE(a);
- PFREE(b);
+ pfree(a);
+ pfree(b);
return (result);
}
Point *
box_center(BOX *box)
{
- Point *result = PALLOCTYPE(Point);
+ Point *result = palloc(sizeof(Point));
result->x = (box->high.x + box->low.x) / 2.0;
result->y = (box->high.y + box->low.y) / 2.0;
b = box_center(box2);
result = HYPOT(a->x - b->x, a->y - b->y);
- PFREE(a);
- PFREE(b);
+ pfree(a);
+ pfree(b);
return (result);
}
if (!box_overlap(box1, box2))
return (NULL);
- result = PALLOCTYPE(BOX);
+ result = palloc(sizeof(BOX));
result->high.x = Min(box1->high.x, box2->high.x);
result->low.x = Max(box1->low.x, box2->low.x);
static LINE * /* point-slope */
line_construct_pm(Point *pt, double m)
{
- LINE *result = PALLOCTYPE(LINE);
+ LINE *result = palloc(sizeof(LINE));
/* use "mx - y + yinter = 0" */
result->A = m;
static LINE * /* two points */
line_construct_pp(Point *pt1, Point *pt2)
{
- LINE *result = PALLOCTYPE(LINE);
+ LINE *result = palloc(sizeof(LINE));
if (FPeq(pt1->x, pt2->x))
{ /* vertical */
double * /* distance between l1, l2 */
line_distance(LINE *l1, LINE *l2)
{
- double *result = PALLOCTYPE(double);
+ double *result = palloc(sizeof(double));
Point *tmp;
if (line_intersect(l1, l2))
{
tmp = point_construct(0.0, l1->C);
result = dist_pl(tmp, l2);
- PFREE(tmp);
+ pfree(tmp);
}
return (result);
}
}
size = offsetof(PATH, p[0]) +(sizeof(path->p[0]) * npts);
- path = PALLOC(size);
+ path = palloc(size);
path->size = size;
path->npts = npts;
int size;
size = offsetof(PATH, p[0]) +(sizeof(path->p[0]) * path->npts);
- result = PALLOC(size);
+ result = palloc(size);
memmove((char *) result, (char *) path, size);
return (result);
if ((min == NULL) || (*min < *tmp))
{
if (min != NULL)
- PFREE(min);
+ pfree(min);
min = tmp;
}
else
{
- PFREE(tmp);
+ pfree(tmp);
}
}
double *result;
int i;
- result = PALLOCTYPE(double);
+ result = palloc(sizeof(double));
*result = 0;
for (i = 0; i < (path->npts - 1); i++)
if (!pair_decode(str, &x, &y, &s) || (strlen(s) > 0))
elog(ERROR, "Bad point external representation '%s'", str);
- point = PALLOCTYPE(Point);
+ point = palloc(sizeof(Point));
point->x = x;
point->y = y;
static Point *
point_construct(double x, double y)
{
- Point *result = PALLOCTYPE(Point);
+ Point *result = palloc(sizeof(Point));
result->x = x;
result->y = y;
if (!PointerIsValid(pt))
return (NULL);
- result = PALLOCTYPE(Point);
+ result = palloc(sizeof(Point));
result->x = pt->x;
result->y = pt->y;
double *
point_distance(Point *pt1, Point *pt2)
{
- double *result = PALLOCTYPE(double);
+ double *result = palloc(sizeof(double));
*result = HYPOT(pt1->x - pt2->x, pt1->y - pt2->y);
return (result);
double *
point_slope(Point *pt1, Point *pt2)
{
- double *result = PALLOCTYPE(double);
+ double *result = palloc(sizeof(double));
if (point_vert(pt1, pt2))
*result = (double) DBL_MAX;
if (!PointerIsValid(str))
elog(ERROR, " Bad (null) lseg external representation", NULL);
- lseg = PALLOCTYPE(LSEG);
+ lseg = palloc(sizeof(LSEG));
if ((!path_decode(TRUE, 2, str, &isopen, &s, &(lseg->p[0])))
|| (*s != '\0'))
LSEG *
lseg_construct(Point *pt1, Point *pt2)
{
- LSEG *result = PALLOCTYPE(LSEG);
+ LSEG *result = palloc(sizeof(LSEG));
result->p[0].x = pt1->x;
result->p[0].y = pt1->y;
else
retval = FALSE;
if (interpt != NULL)
- PFREE(interpt);
- PFREE(ln);
+ pfree(interpt);
+ pfree(ln);
return (retval);
}
double *
lseg_distance(LSEG *l1, LSEG *l2)
{
- double *result = PALLOCTYPE(double);
+ double *result = palloc(sizeof(double));
*result = lseg_dt(l1, l2);
d = dist_ps(&l1->p[0], l2);
result = *d;
- PFREE(d);
+ pfree(d);
d = dist_ps(&l1->p[1], l2);
result = Min(result, *d);
- PFREE(d);
+ pfree(d);
#if FALSE
/* XXX Why are we checking distances from all endpoints to the other segment?
* One set of endpoints should be sufficient - tgl 97/07/03
*/
d = dist_ps(&l2->p[0], l1);
result = Min(result, *d);
- PFREE(d);
+ pfree(d);
d = dist_ps(&l2->p[1], l1);
result = Min(result, *d);
- PFREE(d);
+ pfree(d);
#endif
return (result);
if (!PointerIsValid(lseg))
return (NULL);
- result = PALLOCTYPE(Point);
+ result = palloc(sizeof(Point));
result->x = (lseg->p[0].x - lseg->p[1].x) / 2;
result->y = (lseg->p[0].y - lseg->p[1].y) / 2;
}
else
{
- PFREE(result);
+ pfree(result);
result = NULL;
}
}
- PFREE(tmp1);
- PFREE(tmp2);
+ pfree(tmp1);
+ pfree(tmp2);
return (result);
} /* lseg_interpt() */
double *
dist_pl(Point *pt, LINE *line)
{
- double *result = PALLOCTYPE(double);
+ double *result = palloc(sizeof(double));
*result = (line->A * pt->x + line->B * pt->y + line->C) /
HYPOT(line->A, line->B);
tmpdist = point_distance(pt, &lseg->p[1]);
if (*tmpdist < *result)
*result = *tmpdist;
- PFREE(tmpdist);
+ pfree(tmpdist);
}
if (ip != NULL)
- PFREE(ip);
- PFREE(ln);
+ pfree(ip);
+ pfree(ln);
return (result);
}
* the distance from a point to a path is the smallest
* distance from the point to any of its constituent segments.
*/
- result = PALLOCTYPE(double);
+ result = palloc(sizeof(double));
for (i = 0; i < path->npts - 1; i++)
{
statlseg_construct(&lseg, &path->p[i], &path->p[i + 1]);
tmp = dist_ps(pt, &lseg);
if (i == 0 || *tmp < *result)
*result = *tmp;
- PFREE(tmp);
+ pfree(tmp);
}
break;
}
tmp = close_pb(pt, box);
result = point_distance(tmp, pt);
- PFREE(tmp);
+ pfree(tmp);
return (result);
}
if (inter_sl(lseg, line))
{
- result = PALLOCTYPE(double);
+ result = palloc(sizeof(double));
*result = 0.0;
}
d2 = dist_pl(&lseg->p[1], line);
if (*d2 > *result)
{
- PFREE(result);
+ pfree(result);
result = d2;
}
else
{
- PFREE(d2);
+ pfree(d2);
}
}
tmp = close_sb(lseg, box);
if (tmp == NULL)
{
- result = PALLOCTYPE(double);
+ result = palloc(sizeof(double));
*result = 0.0;
}
else
{
result = dist_pb(tmp, box);
- PFREE(tmp);
+ pfree(tmp);
}
return (result);
tmp = close_lb(line, box);
if (tmp == NULL)
{
- result = PALLOCTYPE(double);
+ result = palloc(sizeof(double));
*result = 0.0;
}
else
{
result = dist_pb(tmp, box);
- PFREE(tmp);
+ pfree(tmp);
}
return (result);
#ifdef GEODEBUG
printf("dist_cpoly- center inside of polygon\n");
#endif
- result = PALLOCTYPE(double);
+ result = palloc(sizeof(double));
*result = 0;
return (result);
#endif
if (*d < *result)
*result = *d;
- PFREE(d);
+ pfree(d);
}
*result -= circle->radius;
}
else
{
- PFREE(p);
+ pfree(p);
p = NULL;
}
}
- PFREE(tmp);
+ pfree(tmp);
return (p);
}
LINE *tmp;
double invm;
- result = PALLOCTYPE(Point);
+ result = palloc(sizeof(Point));
#if FALSE
if (FPeq(line->A, -1.0) && FPzero(line->B))
{ /* vertical */
else
result = point_copy(&lseg->p[1]);
- PFREE(d1);
- PFREE(d2);
+ pfree(d1);
+ pfree(d2);
return (result);
}
tmp = interpt_sl(lseg, line);
if (tmp)
{
- PFREE(tmp);
+ pfree(tmp);
return (1);
}
return (0);
elog(ERROR, "Bad polygon external representation '%s'", str);
size = offsetof(POLYGON, p[0]) +(sizeof(poly->p[0]) * npts);
- poly = PALLOC(size);
+ poly = palloc(size);
MemSet((char *) poly, 0, size); /* zero any holes */
poly->size = size;
if (!PointerIsValid(polya) || !PointerIsValid(polyb))
return (NULL);
- result = PALLOCTYPE(double);
+ result = palloc(sizeof(double));
*result = 0;
if (!(PointerIsValid(p1) && PointerIsValid(p2)))
return (NULL);
- result = PALLOCTYPE(Point);
+ result = palloc(sizeof(Point));
result->x = (p1->x + p2->x);
result->y = (p1->y + p2->y);
if (!(PointerIsValid(p1) && PointerIsValid(p2)))
return (NULL);
- result = PALLOCTYPE(Point);
+ result = palloc(sizeof(Point));
result->x = (p1->x - p2->x);
result->y = (p1->y - p2->y);
if (!(PointerIsValid(p1) && PointerIsValid(p2)))
return (NULL);
- result = PALLOCTYPE(Point);
+ result = palloc(sizeof(Point));
result->x = (p1->x * p2->x) - (p1->y * p2->y);
result->y = (p1->x * p2->y) + (p1->y * p2->x);
if (!(PointerIsValid(p1) && PointerIsValid(p2)))
return (NULL);
- result = PALLOCTYPE(Point);
+ result = palloc(sizeof(Point));
div = (p2->x * p2->x) + (p2->y * p2->y);
low = point_mul(&box->low, p);
result = box_construct(high->x, low->x, high->y, low->y);
- PFREE(high);
- PFREE(low);
+ pfree(high);
+ pfree(low);
return (result);
} /* box_mul() */
low = point_div(&box->low, p);
result = box_construct(high->x, low->x, high->y, low->y);
- PFREE(high);
- PFREE(low);
+ pfree(high);
+ pfree(low);
return (result);
} /* box_div() */
return (NULL);
size = offsetof(PATH, p[0]) +(sizeof(p1->p[0]) * (p1->npts + p2->npts));
- result = PALLOC(size);
+ result = palloc(size);
result->size = size;
result->npts = (p1->npts + p2->npts);
p = point_mul(&path->p[i], point);
result->p[i].x = p->x;
result->p[i].y = p->y;
- PFREE(p);
+ pfree(p);
}
return (result);
p = point_div(&path->p[i], point);
result->p[i].x = p->x;
result->p[i].y = p->y;
- PFREE(p);
+ pfree(p);
}
return (result);
elog(ERROR, "path_center not implemented", NULL);
- result = PALLOCTYPE(Point);
+ result = palloc(sizeof(Point));
result = NULL;
return (result);
elog(ERROR, "Open path cannot be converted to polygon", NULL);
size = offsetof(POLYGON, p[0]) +(sizeof(poly->p[0]) * path->npts);
- poly = PALLOC(size);
+ poly = palloc(size);
poly->size = size;
poly->npts = path->npts;
npts = (path->npts - 1);
size = offsetof(PATH, p[0]) +(sizeof(path->p[0]) * npts);
- result = PALLOC(size);
+ result = palloc(size);
MemSet((char *) result, 0, size);
result->size = size;
if (PointerIsValid(circle = poly_circle(poly)))
{
result = circle_center(circle);
- PFREE(circle);
+ pfree(circle);
}
else
/* map four corners of the box to a polygon */
size = offsetof(POLYGON, p[0]) +(sizeof(poly->p[0]) * 4);
- poly = PALLOC(size);
+ poly = palloc(size);
poly->size = size;
poly->npts = 4;
return (NULL);
size = offsetof(PATH, p[0]) +(sizeof(path->p[0]) * poly->npts);
- path = PALLOC(size);
+ path = palloc(size);
path->size = size;
path->npts = poly->npts;
return (NULL);
size = offsetof(POLYGON, p[0]) +(sizeof(poly->p[0]) * poly->npts);
- result = PALLOC(size);
+ result = palloc(size);
MemSet((char *) result, 0, size);
result->size = size;
return (NULL);
size = offsetof(POLYGON, p[0]) +(sizeof(poly->p[0]) * poly->npts);
- result = PALLOC(size);
+ result = palloc(size);
MemSet((char *) result, 0, size);
result->size = size;
if (!PointerIsValid(str))
elog(ERROR, " Bad (null) circle external representation", NULL);
- circle = PALLOCTYPE(CIRCLE);
+ circle = palloc(sizeof(CIRCLE));
s = str;
while (isspace(*s))
if (!PointerIsValid(circle))
return (NULL);
- result = PALLOC(3 * (P_MAXLEN + 1) + 3);
+ result = palloc(3 * (P_MAXLEN + 1) + 3);
cp = result;
*cp++ = LDELIM_C;
if (!PointerIsValid(circle))
return NULL;
- result = PALLOCTYPE(CIRCLE);
+ result = palloc(sizeof(CIRCLE));
memmove((char *) result, (char *) circle, sizeof(CIRCLE));
return (result);
p = point_mul(&circle->center, point);
result->center.x = p->x;
result->center.y = p->y;
- PFREE(p);
+ pfree(p);
result->radius *= HYPOT(point->x, point->y);
return (result);
p = point_div(&circle->center, point);
result->center.x = p->x;
result->center.y = p->y;
- PFREE(p);
+ pfree(p);
result->radius /= HYPOT(point->x, point->y);
return (result);
{
double *result;
- result = PALLOCTYPE(double);
+ result = palloc(sizeof(double));
*result = circle_ar(circle);
return (result);
{
double *result;
- result = PALLOCTYPE(double);
+ result = palloc(sizeof(double));
*result = (2 * circle->radius);
return (result);
{
double *result;
- result = PALLOCTYPE(double);
+ result = palloc(sizeof(double));
*result = circle->radius;
return (result);
{
double *result;
- result = PALLOCTYPE(double);
+ result = palloc(sizeof(double));
*result = (point_dt(&circle1->center, &circle2->center)
- (circle1->radius + circle2->radius));
if (*result < 0)
d = point_distance(&(circle->center), point);
within = (*d <= circle->radius);
- PFREE(d);
+ pfree(d);
return (within);
} /* circle_contain_pt() */
{
double *result;
- result = PALLOCTYPE(double);
+ result = palloc(sizeof(double));
*result = (point_dt(point, &circle->center) - circle->radius);
if (*result < 0)
{
Point *result;
- result = PALLOCTYPE(Point);
+ result = palloc(sizeof(Point));
result->x = circle->center.x;
result->y = circle->center.y;
if (!(PointerIsValid(center) && PointerIsValid(radius)))
return (NULL);
- result = PALLOCTYPE(CIRCLE);
+ result = palloc(sizeof(CIRCLE));
result->center.x = center->x;
result->center.y = center->y;
if (!PointerIsValid(circle))
return (NULL);
- box = PALLOCTYPE(BOX);
+ box = palloc(sizeof(BOX));
delta = circle->radius / sqrt(2.0e0);
if (!PointerIsValid(box))
return (NULL);
- circle = PALLOCTYPE(CIRCLE);
+ circle = palloc(sizeof(CIRCLE));
circle->center.x = (box->high.x + box->low.x) / 2;
circle->center.y = (box->high.y + box->low.y) / 2;
elog(ERROR, "Unable to convert circle to polygon", NULL);
size = offsetof(POLYGON, p[0]) +(sizeof(poly->p[0]) * npts);
- poly = PALLOC(size);
+ poly = palloc(size);
MemSet((char *) poly, 0, size); /* zero any holes */
poly->size = size;
if (poly->npts < 2)
elog(ERROR, "Unable to convert polygon to circle", NULL);
- circle = PALLOCTYPE(CIRCLE);
+ circle = palloc(sizeof(CIRCLE));
circle->center.x = 0;
circle->center.y = 0;
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/int.c,v 1.12 1998/01/05 16:40:06 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/int.c,v 1.13 1998/01/07 18:46:49 momjian Exp $
*
*-------------------------------------------------------------------------
*/
str = int2out(arg1);
len = (strlen(str) + VARHDRSZ);
- result = PALLOC(len);
+ result = palloc(len);
VARSIZE(result) = len;
memmove(VARDATA(result), str, (len - VARHDRSZ));
- PFREE(str);
+ pfree(str);
return(result);
} /* int2_text() */
len = (VARSIZE(string) - VARHDRSZ);
- str = PALLOC(len+1);
+ str = palloc(len+1);
memmove(str, VARDATA(string), len);
*(str+len) = '\0';
result = int2in(str);
- PFREE(str);
+ pfree(str);
return(result);
} /* text_int2() */
str = int4out(arg1);
len = (strlen(str) + VARHDRSZ);
- result = PALLOC(len);
+ result = palloc(len);
VARSIZE(result) = len;
memmove(VARDATA(result), str, (len - VARHDRSZ));
- PFREE(str);
+ pfree(str);
return(result);
} /* int4_text() */
len = (VARSIZE(string) - VARHDRSZ);
- str = PALLOC(len+1);
+ str = palloc(len+1);
memmove(str, VARDATA(string), len);
*(str+len) = '\0';
result = int4in(str);
- PFREE(str);
+ pfree(str);
return(result);
} /* text_int4() */
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/nabstime.c,v 1.38 1998/01/05 16:40:07 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/nabstime.c,v 1.39 1998/01/07 18:46:50 momjian Exp $
*
*-------------------------------------------------------------------------
*/
break;
}
- result = PALLOC(strlen(buf) + 1);
+ result = palloc(strlen(buf) + 1);
strcpy(result, buf);
return (result);
{
DateTime *result;
- if (!PointerIsValid(result = PALLOCTYPE(DateTime)))
+ if (!PointerIsValid(result = palloc(sizeof(DateTime))))
elog(ERROR, "Unable to allocate space to convert abstime to datetime", NULL);
switch (abstime)
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/oid.c,v 1.12 1997/10/25 05:21:54 thomas Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/oid.c,v 1.13 1998/01/07 18:46:50 momjian Exp $
*
*-------------------------------------------------------------------------
*/
str = oidout(oid);
len = (strlen(str) + VARHDRSZ);
- result = PALLOC(len);
+ result = palloc(len);
VARSIZE(result) = len;
memmove(VARDATA(result), str, (len-VARHDRSZ));
- PFREE(str);
+ pfree(str);
return(result);
} /* oid_text() */
len = (VARSIZE(string) - VARHDRSZ);
- str = PALLOC(len+1);
+ str = palloc(len+1);
memmove(str, VARDATA(string), len);
*(str+len) = '\0';
result = oidin(str);
- PFREE(str);
+ pfree(str);
return(result);
} /* oid_text() */
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/varchar.c,v 1.16 1998/01/05 16:40:18 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/varchar.c,v 1.17 1998/01/07 18:46:52 momjian Exp $
*
*-------------------------------------------------------------------------
*/
typlen = len + VARHDRSZ;
}
else
- {
len = typlen - VARHDRSZ;
- }
if (len > 4096)
elog(ERROR, "bpcharin: length of char() must be less than 4096");
result = (char *) palloc(typlen);
- *(int32 *) result = typlen;
- r = result + VARHDRSZ;
+ VARSIZE(result) = typlen;
+ r = VARDATA(result);
for (i = 0; i < len; i++, r++, s++)
{
*r = *s;
}
else
{
- len = *(int32 *) s - VARHDRSZ;
+ len = VARSIZE(s) - VARHDRSZ;
result = (char *) palloc(len + 1);
- StrNCpy(result, s + VARHDRSZ, len+1); /* these are blank-padded */
+ StrNCpy(result, VARDATA(s), len+1); /* these are blank-padded */
}
return (result);
}
varcharin(char *s, int dummy, int typlen)
{
char *result;
- int len = typlen - VARHDRSZ;
+ int len;
if (s == NULL)
return ((char *) NULL);
- if (typlen == -1)
- {
-
- /*
- * this is here because some functions can't supply the typlen
- */
- len = strlen(s);
- typlen = len + VARHDRSZ;
- }
+ len = strlen(s) + VARHDRSZ;
+ if (typlen != -1 && len > typlen)
+ len = typlen; /* clip the string at max length */
if (len > 4096)
elog(ERROR, "varcharin: length of char() must be less than 4096");
- result = (char *) palloc(typlen);
- *(int32 *) result = typlen;
- strncpy(result + VARHDRSZ, s, len+1);
+ result = (char *) palloc(len);
+ VARSIZE(result) = len;
+ memmove(VARDATA(result), s, len - VARHDRSZ);
return (result);
}
}
else
{
- len = *(int32 *) s - VARHDRSZ;
+ len = VARSIZE(s) - VARHDRSZ;
result = (char *) palloc(len + 1);
- StrNCpy(result, s + VARHDRSZ, len+1);
+ StrNCpy(result, VARDATA(s), len+1);
}
return (result);
}
static int
bcTruelen(char *arg)
{
- char *s = arg + VARHDRSZ;
+ char *s = VARDATA(arg);
int i;
int len;
- len = *(int32 *) arg - VARHDRSZ;
+ len = VARSIZE(arg) - VARHDRSZ;
for (i = len - 1; i >= 0; i--)
{
if (s[i] != ' ')
if (len1 != len2)
return 0;
- return (strncmp(arg1 + VARHDRSZ, arg2 + VARHDRSZ, len1) == 0);
+ return (strncmp(VARDATA(arg1), VARDATA(arg2), len1) == 0);
}
bool
if (len1 != len2)
return 1;
- return (strncmp(arg1 + VARHDRSZ, arg2 + VARHDRSZ, len1) != 0);
+ return (strncmp(VARDATA(arg1), VARDATA(arg2), len1) != 0);
}
bool
len1 = bcTruelen(arg1);
len2 = bcTruelen(arg2);
- cmp = strncmp(arg1 + VARHDRSZ, arg2 + VARHDRSZ, Min(len1, len2));
+ cmp = strncmp(VARDATA(arg1), VARDATA(arg2), Min(len1, len2));
if (cmp == 0)
return (len1 < len2);
else
len1 = bcTruelen(arg1);
len2 = bcTruelen(arg2);
- cmp = strncmp(arg1 + VARHDRSZ, arg2 + VARHDRSZ, Min(len1, len2));
+ cmp = strncmp(VARDATA(arg1), VARDATA(arg2), Min(len1, len2));
if (0 == cmp)
return (bool) (len1 <= len2 ? 1 : 0);
else
len1 = bcTruelen(arg1);
len2 = bcTruelen(arg2);
- cmp = strncmp(arg1 + VARHDRSZ, arg2 + VARHDRSZ, Min(len1, len2));
+ cmp = strncmp(VARDATA(arg1), VARDATA(arg2), Min(len1, len2));
if (cmp == 0)
return (len1 > len2);
else
len1 = bcTruelen(arg1);
len2 = bcTruelen(arg2);
- cmp = strncmp(arg1 + VARHDRSZ, arg2 + VARHDRSZ, Min(len1, len2));
+ cmp = strncmp(VARDATA(arg1), VARDATA(arg2), Min(len1, len2));
if (0 == cmp)
return (bool) (len1 >= len2 ? 1 : 0);
else
len1 = bcTruelen(arg1);
len2 = bcTruelen(arg2);
- cmp = strncmp(arg1 + VARHDRSZ, arg2 + VARHDRSZ, Min(len1, len2));
+ cmp = strncmp(VARDATA(arg1), VARDATA(arg2), Min(len1, len2));
if ((0 == cmp) && (len1 != len2))
return (int32) (len1 < len2 ? -1 : 1);
else
* Comparison Functions used for varchar
*****************************************************************************/
-static int
-vcTruelen(char *arg)
-{
- char *s = arg + VARHDRSZ;
- int i;
- int len;
-
- len = *(int32 *) arg - VARHDRSZ;
- for (i = 0; i < len; i++)
- {
- if (*s++ == '\0')
- break;
- }
- return i;
-}
-
int32
varcharlen(char *arg)
{
if (!PointerIsValid(arg))
elog(ERROR, "Bad (null) varchar() external representation", NULL);
- return(vcTruelen(arg));
-} /* vclen() */
+ return VARSIZE(arg);
+}
bool
varchareq(char *arg1, char *arg2)
if (arg1 == NULL || arg2 == NULL)
return ((bool) 0);
- len1 = vcTruelen(arg1);
- len2 = vcTruelen(arg2);
+ len1 = VARSIZE(arg1);
+ len2 = VARSIZE(arg2);
if (len1 != len2)
return 0;
- return (strncmp(arg1 + VARHDRSZ, arg2 + VARHDRSZ, len1) == 0);
+ return (strncmp(VARDATA(arg1), VARDATA(arg2), len1) == 0);
}
bool
if (arg1 == NULL || arg2 == NULL)
return ((bool) 0);
- len1 = vcTruelen(arg1);
- len2 = vcTruelen(arg2);
+ len1 = VARSIZE(arg1);
+ len2 = VARSIZE(arg2);
if (len1 != len2)
return 1;
- return (strncmp(arg1 + VARHDRSZ, arg2 + VARHDRSZ, len1) != 0);
+ return (strncmp(VARDATA(arg1), VARDATA(arg2), len1) != 0);
}
bool
if (arg1 == NULL || arg2 == NULL)
return ((bool) 0);
- len1 = vcTruelen(arg1);
- len2 = vcTruelen(arg2);
+ len1 = VARSIZE(arg1);
+ len2 = VARSIZE(arg2);
- cmp = strncmp(arg1 + VARHDRSZ, arg2 + VARHDRSZ, Min(len1, len2));
+ cmp = strncmp(VARDATA(arg1), VARDATA(arg2), Min(len1, len2));
if (cmp == 0)
return (len1 < len2);
else
if (arg1 == NULL || arg2 == NULL)
return ((bool) 0);
- len1 = vcTruelen(arg1);
- len2 = vcTruelen(arg2);
+ len1 = VARSIZE(arg1);
+ len2 = VARSIZE(arg2);
- cmp = strncmp(arg1 + VARHDRSZ, arg2 + VARHDRSZ, Min(len1, len2));
+ cmp = strncmp(VARDATA(arg1), VARDATA(arg2), Min(len1, len2));
if (0 == cmp)
return (bool) (len1 <= len2 ? 1 : 0);
else
if (arg1 == NULL || arg2 == NULL)
return ((bool) 0);
- len1 = vcTruelen(arg1);
- len2 = vcTruelen(arg2);
+ len1 = VARSIZE(arg1);
+ len2 = VARSIZE(arg2);
- cmp = strncmp(arg1 + VARHDRSZ, arg2 + VARHDRSZ, Min(len1, len2));
+ cmp = strncmp(VARDATA(arg1), VARDATA(arg2), Min(len1, len2));
if (cmp == 0)
return (len1 > len2);
else
if (arg1 == NULL || arg2 == NULL)
return ((bool) 0);
- len1 = vcTruelen(arg1);
- len2 = vcTruelen(arg2);
+ len1 = VARSIZE(arg1);
+ len2 = VARSIZE(arg2);
- cmp = strncmp(arg1 + VARHDRSZ, arg2 + VARHDRSZ, Min(len1, len2));
+ cmp = strncmp(VARDATA(arg1), VARDATA(arg2), Min(len1, len2));
if (0 == cmp)
return (bool) (len1 >= len2 ? 1 : 0);
else
len2;
int cmp;
- len1 = vcTruelen(arg1);
- len2 = vcTruelen(arg2);
- cmp = (strncmp(arg1 + VARHDRSZ, arg2 + VARHDRSZ, Min(len1, len2)));
+ len1 = VARSIZE(arg1);
+ len2 = VARSIZE(arg2);
+ cmp = (strncmp(VARDATA(arg1), VARDATA(arg2), Min(len1, len2)));
if ((0 == cmp) && (len1 != len2))
return (int32) (len1 < len2 ? -1 : 1);
else
int loop;
keydata = VARDATA(key);
- keylen = vcTruelen((char *) key);
+ keylen = VARSIZE((char *) key);
#define HASHC n = *keydata++ + 65599 * n
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/varlena.c,v 1.28 1998/01/05 16:40:20 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/varlena.c,v 1.29 1998/01/07 18:46:54 momjian Exp $
*
*-------------------------------------------------------------------------
*/
while (len2 > 0 && VARDATA(t2)[len2 - 1] == '\0')
len2--;
- result = PALLOC(len = len1 + len2 + VARHDRSZ);
+ result = palloc(len = len1 + len2 + VARHDRSZ);
/* Fill data field of result string... */
ptr = VARDATA(result);
n = (len-m);
}
- ret = (text *) PALLOC(VARHDRSZ + n);
+ ret = (text *) palloc(VARHDRSZ + n);
VARSIZE(ret) = VARHDRSZ + n;
memcpy(VARDATA(ret), VARDATA(string)+m, n);
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: geo_decls.h,v 1.15 1997/09/25 16:52:23 momjian Exp $
+ * $Id: geo_decls.h,v 1.16 1998/01/07 18:46:59 momjian Exp $
*
* NOTE
* These routines do *not* use the float types from adt/.
#include "access/attnum.h"
-/*#ifndef FmgrIncluded -- seems like always included. (it's FMgrIncluded) AY */
-
/*--------------------------------------------------------------------
* Useful floating point utilities and constants.
*-------------------------------------------------------------------*/
#define HYPOT(A, B) sqrt((A) * (A) + (B) * (B))
-/*--------------------------------------------------------------------
- * Memory management.
- *-------------------------------------------------------------------*/
-
-#define PALLOC(SIZE) palloc(SIZE)
-#define PFREE(P) pfree(P)
-#define PALLOCTYPE(TYPE) (TYPE *) PALLOC(sizeof(TYPE))
-
-/*#endif !FmgrIncluded */
-
/*---------------------------------------------------------------------
* Point - (x,y)
*-------------------------------------------------------------------*/
/*
- * $Header: /cvsroot/pgsql/src/test/regress/regress.c,v 1.20 1998/01/06 19:24:52 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/test/regress/regress.c,v 1.21 1998/01/07 18:47:07 momjian Exp $
*/
#include <float.h> /* faked on sunos */
switch (path->npts)
{
case 0:
- result = PALLOCTYPE(double);
+ result = palloc(sizeof(double));
*result = Abs((double) DBL_MAX); /* +infinity */
break;
case 1:
* distance from the point to any of its constituent segments.
*/
Assert(path->npts > 1);
- result = PALLOCTYPE(double);
+ result = palloc(sizeof(double));
for (i = 0; i < path->npts - 1; ++i)
{
regress_lseg_construct(&lseg, &path->p[i], &path->p[i + 1]);
tmp = dist_ps(pt, &lseg);
if (i == 0 || *tmp < *result)
*result = *tmp;
- PFREE(tmp);
+ pfree(tmp);
}
break;
if (*min < *(tmp = lseg_distance(&seg1, &seg2)))
*min = *tmp;
- PFREE(tmp);
+ pfree(tmp);
}
return (min);
POLYGON *poly;
{
int i;
- char *output = (char *) PALLOC(2 * (P_MAXDIG + 1) * poly->npts + 64);
+ char *output = (char *) palloc(2 * (P_MAXDIG + 1) * poly->npts + 64);
char buf[2 * (P_MAXDIG) + 20];
sprintf(output, "(1, %*d", P_MAXDIG, poly->npts);