]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - ppdc/ppdc-array.cxx
Don't generate certificates that expire on Feb 29th (Issue #5643)
[thirdparty/cups.git] / ppdc / ppdc-array.cxx
index e23b4e0e140bda994bfb5f7677db4b511445e627..3a0cab33be48535b3877b7c3c51674ca9d0475fd 100644 (file)
@@ -1,32 +1,17 @@
 //
-// "$Id$"
+// Array class for the CUPS PPD Compiler.
 //
-//   Array class for the CUPS PPD Compiler.
+// Copyright 2007-2019 by Apple Inc.
+// Copyright 2002-2005 by Easy Software Products.
 //
-//   Copyright 2007-2008 by Apple Inc.
-//   Copyright 2002-2005 by Easy Software Products.
-//
-//   These coded instructions, statements, and computer programs are the
-//   property of Apple Inc. and are protected by Federal copyright
-//   law.  Distribution and use rights are outlined in the file "LICENSE.txt"
-//   which should have been included with this file.  If this file is
-//   file is missing or damaged, see the license at "http://www.cups.org/".
-//
-// Contents:
-//
-//   ppdcArray::ppdcArray()  - Create a new array.
-//   ppdcArray::~ppdcArray() - Destroy an array.
-//   ppdcArray::add()        - Add an element to an array.
-//   ppdcArray::first()      - Return the first element in the array.
-//   ppdcArray::next()       - Return the next element in the array.
-//   ppdcArray::remove()     - Remove an element from the array.
+// Licensed under Apache License v2.0.  See the file "LICENSE" for more information.
 //
 
 //
 // Include necessary headers...
 //
 
-#include "ppdc.h"
+#include "ppdc-private.h"
 
 
 //
 //
 
 ppdcArray::ppdcArray(ppdcArray *a)
+  : ppdcShared()
 {
+  PPDC_NEW;
+
   if (a)
   {
     count = a->count;
@@ -45,10 +33,10 @@ ppdcArray::ppdcArray(ppdcArray *a)
       // Make a copy of the array...
       data = new ppdcShared *[count];
 
-      memcpy(data, a->data, count * sizeof(ppdcShared *));
+      memcpy(data, a->data, (size_t)count * sizeof(ppdcShared *));
 
-      for (int i = 0; i < count; i ++)
-        data[i]->get();
+      for (size_t i = 0; i < count; i ++)
+        data[i]->retain();
     }
     else
       data = 0;
@@ -70,7 +58,9 @@ ppdcArray::ppdcArray(ppdcArray *a)
 
 ppdcArray::~ppdcArray()
 {
-  for (int i = 0; i < count; i ++)
+  PPDC_DELETE;
+
+  for (size_t i = 0; i < count; i ++)
     data[i]->release();
 
   if (alloc)
@@ -93,7 +83,7 @@ ppdcArray::add(ppdcShared *d)
     alloc += 10;
     temp  = new ppdcShared *[alloc];
 
-    memcpy(temp, data, count * sizeof(ppdcShared *));
+    memcpy(temp, data, (size_t)count * sizeof(ppdcShared *));
 
     delete[] data;
     data = temp;
@@ -140,7 +130,7 @@ ppdcArray::next()
 void
 ppdcArray::remove(ppdcShared *d)               // I - Data element
 {
-  int  i;                                      // Looping var
+  size_t       i;                              // Looping var
 
 
   for (i = 0; i < count; i ++)
@@ -154,10 +144,5 @@ ppdcArray::remove(ppdcShared *d)           // I - Data element
   d->release();
 
   if (i < count)
-    memmove(data + i, data + i + 1, (count - i) * sizeof(ppdcShared *));
+    memmove(data + i, data + i + 1, (size_t)(count - i) * sizeof(ppdcShared *));
 }
-
-
-//
-// End of "$Id$".
-//