88 *
99 *
1010 * IDENTIFICATION
11- * $Header: /cvsroot/pgsql/src/backend/access/common/heaptuple.c,v 1.59 1999/12/16 22:19:34 wieck Exp $
11+ * $Header: /cvsroot/pgsql/src/backend/access/common/heaptuple.c,v 1.60 2000/01/15 02:59:17 petere Exp $
1212 *
1313 * NOTES
1414 * The old interface functions have been converted to macros
@@ -136,8 +136,9 @@ DataFill(char *data,
136136* ((int32 * )value [i ]));
137137break ;
138138default :
139- memmove (data ,DatumGetPointer (value [i ]),
140- att [i ]-> attlen );
139+ Assert (att [i ]-> attlen >=0 );
140+ memmove (data ,DatumGetPointer (value [i ]),
141+ (size_t )(att [i ]-> attlen ));
141142break ;
142143}
143144data = (char * )att_addlength ((long )data ,att [i ]-> attlen ,value [i ]);
@@ -324,8 +325,8 @@ nocachegetattr(HeapTuple tuple,
324325Form_pg_attribute * att = tupleDesc -> attrs ;
325326int slow = 0 ;/* do we have to walk nulls? */
326327
327-
328- #if IN_MACRO
328+ ( void ) isnull ; /*not used*/
329+ #ifdef IN_MACRO
329330/* This is handled in the macro */
330331Assert (attnum > 0 );
331332
@@ -346,7 +347,7 @@ nocachegetattr(HeapTuple tuple,
346347
347348if (HeapTupleNoNulls (tuple ))
348349{
349- #if IN_MACRO
350+ #ifdef IN_MACRO
350351/* This is handled in the macro */
351352if (att [attnum ]-> attcacheoff != -1 )
352353{
@@ -376,7 +377,7 @@ nocachegetattr(HeapTuple tuple,
376377 * ----------------
377378 */
378379
379- #if IN_MACRO
380+ #ifdef IN_MACRO
380381/* This is handled in the macro */
381382if (att_isnull (attnum ,bp ))
382383{
@@ -565,7 +566,7 @@ heap_copytuple(HeapTuple tuple)
565566newTuple -> t_datamcxt = CurrentMemoryContext ;
566567newTuple -> t_data = (HeapTupleHeader ) ((char * )newTuple + HEAPTUPLESIZE );
567568memmove ((char * )newTuple -> t_data ,
568- (char * )tuple -> t_data ,( int ) tuple -> t_len );
569+ (char * )tuple -> t_data ,tuple -> t_len );
569570return newTuple ;
570571}
571572
@@ -589,7 +590,7 @@ heap_copytuple_with_tuple(HeapTuple src, HeapTuple dest)
589590dest -> t_datamcxt = CurrentMemoryContext ;
590591dest -> t_data = (HeapTupleHeader )palloc (src -> t_len );
591592memmove ((char * )dest -> t_data ,
592- (char * )src -> t_data ,( int ) src -> t_len );
593+ (char * )src -> t_data ,src -> t_len );
593594return ;
594595}
595596
@@ -655,7 +656,7 @@ heap_formtuple(TupleDesc tupleDescriptor,
655656HeapTuple tuple ;/* return tuple */
656657HeapTupleHeader td ;/* tuple data */
657658int bitmaplen ;
658- long len ;
659+ unsigned longlen ;
659660int hoff ;
660661bool hasnull = false;
661662int i ;
@@ -687,7 +688,7 @@ heap_formtuple(TupleDesc tupleDescriptor,
687688tuple -> t_datamcxt = CurrentMemoryContext ;
688689td = tuple -> t_data = (HeapTupleHeader ) ((char * )tuple + HEAPTUPLESIZE );
689690
690- MemSet ((char * )td ,0 ,( int ) len );
691+ MemSet ((char * )td ,0 ,len );
691692
692693tuple -> t_len = len ;
693694ItemPointerSetInvalid (& (tuple -> t_self ));
@@ -803,8 +804,6 @@ heap_modifytuple(HeapTuple tuple,
803804void
804805heap_freetuple (HeapTuple htup )
805806{
806- extern int getpid ();
807-
808807if (htup -> t_data != NULL )
809808if (htup -> t_datamcxt != NULL && (char * )(htup -> t_data )!=
810809((char * )htup + HEAPTUPLESIZE ))
@@ -828,7 +827,7 @@ heap_addheader(uint32 natts,/* max domain index */
828827{
829828HeapTuple tuple ;
830829HeapTupleHeader td ;/* tuple data */
831- long len ;
830+ unsigned longlen ;
832831int hoff ;
833832
834833AssertArg (natts > 0 );
@@ -841,7 +840,7 @@ heap_addheader(uint32 natts,/* max domain index */
841840tuple -> t_datamcxt = CurrentMemoryContext ;
842841td = tuple -> t_data = (HeapTupleHeader ) ((char * )tuple + HEAPTUPLESIZE );
843842
844- MemSet ((char * )td ,0 ,( int ) len );
843+ MemSet ((char * )td ,0 ,len );
845844
846845tuple -> t_len = len ;
847846ItemPointerSetInvalid (& (tuple -> t_self ));
@@ -850,7 +849,8 @@ heap_addheader(uint32 natts,/* max domain index */
850849td -> t_infomask = 0 ;
851850td -> t_infomask |=HEAP_XMAX_INVALID ;
852851
853- memmove ((char * )td + hoff ,structure ,structlen );
852+ if (structlen > 0 )
853+ memmove ((char * )td + hoff ,structure , (size_t )structlen );
854854
855855return tuple ;
856856}