]> git.kaiwu.me - njs.git/commitdiff
Removed misused __attribute__((malloc)).
authorValentin Bartenev <vbart@nginx.com>
Thu, 10 Nov 2016 13:47:52 +0000 (16:47 +0300)
committerValentin Bartenev <vbart@nginx.com>
Thu, 10 Nov 2016 13:47:52 +0000 (16:47 +0300)
According to the documentation:

| This tells the compiler that a function is malloc-like, i.e., that the
| pointer P returned by the function cannot alias any other pointer valid
| when the function returns, and moreover no pointers to valid objects
| occur in any storage addressed by P.

The njs_string_alloc() allocates a storage for a string and makes the
storage accessible via the passed "value" argument.  The function also
returns an intermediate pointer which is used only for string content
initialization and then discarded.  Since the pointer is not stored
anywhere after the initialization, GCC with -O or higher optimisation
levels rightfully optimizes out the initialization.

njs/njs_string.h

index a06a3cc29f493a69b9df4a126d19f27a5e4f7ea0..054944dd5fd2f245eb8ee5be97a5c8875ce4c0eb 100644 (file)
@@ -112,8 +112,7 @@ njs_string_length(njs_utf8_t utf8, u_char *start, size_t size)
 njs_ret_t njs_string_new(njs_vm_t *vm, njs_value_t *value, const u_char *start,
     uint32_t size, uint32_t length);
 u_char *njs_string_alloc(njs_vm_t *vm, njs_value_t *value, uint32_t size,
-    uint32_t length)
-    NXT_MALLOC_LIKE;
+    uint32_t length);
 void njs_string_copy(njs_value_t *dst, njs_value_t *src);
 njs_ret_t njs_string_validate(njs_vm_t *vm, njs_string_prop_t *string,
     njs_value_t *value);