mike-jumper commented on code in PR #525:
URL: https://github.com/apache/guacamole-server/pull/525#discussion_r1742771893


##########
src/libguac/guacamole/rect.h:
##########
@@ -0,0 +1,256 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#ifndef GUAC_RECT_H
+#define GUAC_RECT_H
+
+#include "mem.h"
+#include "rect-types.h"
+
+/**
+ * Returns the memory address of given rectangle within the given mutable
+ * buffer, where the upper-left corner of the given buffer is (0, 0). If the
+ * memory address cannot be calculated because doing so would overflow the
+ * maximum value of a size_t, execution of the current process is automatically
+ * aborted.
+ *
+ * IMPORTANT: No checks are performed on whether the rectangle extends beyond
+ * the bounds of the buffer, including considering whether the left/top
+ * position of the rectangle is negative. If the rectangle has not already been
+ * contrained to be within the bounds of the buffer, such checks must be
+ * performed before dereferencing the value returned by this macro.
+ *
+ * @param rect
+ *     The rectangle to determine the offset of.
+ *
+ * @param buffer
+ *     The mutable buffer within which the address of given rectangle should be
+ *     determined.
+ *
+ * @param stride
+ *     The number of bytes in each row of image data within the buffer.
+ *
+ * @param bpp
+ *     The number of bytes in each pixel of image data.
+ *
+ * @return
+ *     The memory address of given rectangle within the given buffer.
+ */
+#define GUAC_RECT_MUTABLE_BUFFER(rect, buffer, stride, bpp) ((void*) (        \
+            ((unsigned char*) (buffer))                                       \
+                + guac_mem_ckd_mul_or_die((rect).top, stride)                 \
+                + guac_mem_ckd_mul_or_die((rect).left, bpp)))
+
+/**
+ * Returns the memory address of given rectangle within the given immutable

Review Comment:
   Ooof, I say "of given rectangle" nearly everywhere... I'll fix all the 
occurrences.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@guacamole.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to