Re: [JGIT PATCH 2/5] Fix UnpackedObjectLoader.getBytes to return a copy

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Oct 1, 2008 at 03:31, Shawn O. Pearce <spearce@xxxxxxxxxxx> wrote:
> diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectLoader.java b/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectLoader.java
> index 5282491..87e861f 100644
> --- a/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectLoader.java
> +++ b/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectLoader.java
> @@ -105,7 +105,12 @@ protected void setId(final ObjectId id) {
>         * @throws IOException
>         *             the object cannot be read.
>         */
> -       public abstract byte[] getBytes() throws IOException;
> +       public final byte[] getBytes() throws IOException {
> +               final byte[] data = getCachedBytes();
> +               final byte[] copy = new byte[data.length];
> +               System.arraycopy(data, 0, copy, 0, data.length);
> +               return data;
> +       }

If I understand correctly, shouldn't this return the copy variable?

-- 
Jonas Fonseca
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux