On 04-Sep-20 11:11 PM, Stephen Hemminger wrote:
By using the alloc_size() attribute the compiler can optimize
better and detect errors at compile time.

For example, Gcc will fail one of the invalid allocation examples
in app/test/test_malloc.c because the allocation is outside the
limits of memory.

Signed-off-by: Stephen Hemminger <step...@networkplumber.org>
---

This is a very cool feature! LGTM

Acked-by: Anatoly Burakov <anatoly.bura...@intel.com>

  void *
-rte_zmalloc_socket(const char *type, size_t size, unsigned align, int socket);
+rte_zmalloc_socket(const char *type, size_t size, unsigned align, int socket)
+       __rte_alloc_size(2);
/**
   * Replacement function for calloc(), using huge-page memory. Memory area is
@@ -239,9 +243,9 @@ rte_zmalloc_socket(const char *type, size_t size, unsigned 
align, int socket);
   *     align is not a power of two).
   *   - Otherwise, the pointer to the allocated object.
   */
-__rte_malloc
  void *

Where did this come from?

-rte_calloc_socket(const char *type, size_t num, size_t size, unsigned align, 
int socket);
+rte_calloc_socket(const char *type, size_t num, size_t size, unsigned align, 
int socket)
+       __rte_alloc_size(2, 3);
/**
   * Frees the memory space pointed to by the provided pointer.



--
Thanks,
Anatoly

Reply via email to