From 45063953fd3f2c25c7f8cc65860b32a35b3ba80e Mon Sep 17 00:00:00 2001 From: Guus Sliepen Date: Fri, 10 May 2013 20:15:27 +0200 Subject: [PATCH] Add more __attribute__((malloc)) where appropriate. --- src/cipher.h | 6 +++--- src/digest.h | 6 +++--- src/ecdh.h | 2 +- src/ecdsa.h | 6 +++--- src/ecdsagen.h | 2 +- src/netutl.h | 4 ++-- src/rsa.h | 8 ++++---- src/rsagen.h | 2 +- src/splay_tree.h | 4 ++-- 9 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/cipher.h b/src/cipher.h index a3bdc2e7..c586fffb 100644 --- a/src/cipher.h +++ b/src/cipher.h @@ -26,9 +26,9 @@ typedef struct cipher cipher_t; -extern cipher_t *cipher_open_by_name(const char *); -extern cipher_t *cipher_open_by_nid(int); -extern cipher_t *cipher_open_blowfish_ofb(void); +extern cipher_t *cipher_open_by_name(const char *) __attribute__ ((__malloc__)); +extern cipher_t *cipher_open_by_nid(int) __attribute__ ((__malloc__)); +extern cipher_t *cipher_open_blowfish_ofb(void) __attribute__ ((__malloc__)); extern void cipher_close(cipher_t *); extern size_t cipher_keylength(const cipher_t *); extern void cipher_get_key(const cipher_t *, void *); diff --git a/src/digest.h b/src/digest.h index 848b9110..bd9e5875 100644 --- a/src/digest.h +++ b/src/digest.h @@ -24,9 +24,9 @@ typedef struct digest digest_t; -extern digest_t *digest_open_by_name(const char *name, int maclength); -extern digest_t *digest_open_by_nid(int nid, int maclength); -extern digest_t *digest_open_sha1(int maclength); +extern digest_t *digest_open_by_name(const char *name, int maclength) __attribute__ ((__malloc__)); +extern digest_t *digest_open_by_nid(int nid, int maclength) __attribute__ ((__malloc__)); +extern digest_t *digest_open_sha1(int maclength) __attribute__ ((__malloc__)); extern void digest_close(digest_t *); extern bool digest_create(digest_t *, const void *indata, size_t inlen, void *outdata); extern bool digest_verify(digest_t *, const void *indata, size_t inlen, const void *digestdata); diff --git a/src/ecdh.h b/src/ecdh.h index 6d3b2f10..881ee924 100644 --- a/src/ecdh.h +++ b/src/ecdh.h @@ -27,7 +27,7 @@ typedef struct ecdh ecdh_t; #endif -extern ecdh_t *ecdh_generate_public(void *pubkey); +extern ecdh_t *ecdh_generate_public(void *pubkey) __attribute__ ((__malloc__)); extern bool ecdh_compute_shared(ecdh_t *ecdh, const void *pubkey, void *shared); extern void ecdh_free(ecdh_t *ecdh); diff --git a/src/ecdsa.h b/src/ecdsa.h index eac3871c..95612390 100644 --- a/src/ecdsa.h +++ b/src/ecdsa.h @@ -24,10 +24,10 @@ typedef struct ecdsa ecdsa_t; #endif -extern ecdsa_t *ecdsa_set_base64_public_key(const char *p); +extern ecdsa_t *ecdsa_set_base64_public_key(const char *p) __attribute__ ((__malloc__)); extern char *ecdsa_get_base64_public_key(ecdsa_t *ecdsa); -extern ecdsa_t *ecdsa_read_pem_public_key(FILE *fp); -extern ecdsa_t *ecdsa_read_pem_private_key(FILE *fp); +extern ecdsa_t *ecdsa_read_pem_public_key(FILE *fp) __attribute__ ((__malloc__)); +extern ecdsa_t *ecdsa_read_pem_private_key(FILE *fp) __attribute__ ((__malloc__)); extern size_t ecdsa_size(ecdsa_t *ecdsa); extern bool ecdsa_sign(ecdsa_t *ecdsa, const void *in, size_t inlen, void *out); extern bool ecdsa_verify(ecdsa_t *ecdsa, const void *in, size_t inlen, const void *out); diff --git a/src/ecdsagen.h b/src/ecdsagen.h index 2f373ab4..621913bc 100644 --- a/src/ecdsagen.h +++ b/src/ecdsagen.h @@ -22,7 +22,7 @@ #include "ecdsa.h" -extern ecdsa_t *ecdsa_generate(void); +extern ecdsa_t *ecdsa_generate(void) __attribute__ ((__malloc__)); extern bool ecdsa_write_pem_public_key(ecdsa_t *ecdsa, FILE *fp); extern bool ecdsa_write_pem_private_key(ecdsa_t *ecdsa, FILE *fp); diff --git a/src/netutl.h b/src/netutl.h index 0fef2d6e..57888f53 100644 --- a/src/netutl.h +++ b/src/netutl.h @@ -25,10 +25,10 @@ extern bool hostnames; -extern struct addrinfo *str2addrinfo(const char *, const char *, int); +extern struct addrinfo *str2addrinfo(const char *, const char *, int) __attribute__ ((__malloc__)); extern sockaddr_t str2sockaddr(const char *, const char *); extern void sockaddr2str(const sockaddr_t *, char **, char **); -extern char *sockaddr2hostname(const sockaddr_t *); +extern char *sockaddr2hostname(const sockaddr_t *) __attribute__ ((__malloc__)); extern int sockaddrcmp(const sockaddr_t *, const sockaddr_t *); extern int sockaddrcmp_noport(const sockaddr_t *, const sockaddr_t *); extern void sockaddrunmap(sockaddr_t *); diff --git a/src/rsa.h b/src/rsa.h index 5b539038..64344b74 100644 --- a/src/rsa.h +++ b/src/rsa.h @@ -25,10 +25,10 @@ typedef struct rsa rsa_t; #endif extern void rsa_free(rsa_t *rsa); -extern rsa_t *rsa_set_hex_public_key(char *n, char *e); -extern rsa_t *rsa_set_hex_private_key(char *n, char *e, char *d); -extern rsa_t *rsa_read_pem_public_key(FILE *fp); -extern rsa_t *rsa_read_pem_private_key(FILE *fp); +extern rsa_t *rsa_set_hex_public_key(char *n, char *e) __attribute__ ((__malloc__)); +extern rsa_t *rsa_set_hex_private_key(char *n, char *e, char *d) __attribute__ ((__malloc__)); +extern rsa_t *rsa_read_pem_public_key(FILE *fp) __attribute__ ((__malloc__)); +extern rsa_t *rsa_read_pem_private_key(FILE *fp) __attribute__ ((__malloc__)); extern size_t rsa_size(rsa_t *rsa); extern bool rsa_public_encrypt(rsa_t *rsa, void *in, size_t len, void *out); extern bool rsa_private_decrypt(rsa_t *rsa, void *in, size_t len, void *out); diff --git a/src/rsagen.h b/src/rsagen.h index 3f9c8248..84cd0bb4 100644 --- a/src/rsagen.h +++ b/src/rsagen.h @@ -22,7 +22,7 @@ #include "rsa.h" -extern rsa_t *rsa_generate(size_t bits, unsigned long exponent); +extern rsa_t *rsa_generate(size_t bits, unsigned long exponent) __attribute__ ((__malloc__)); extern bool rsa_write_pem_public_key(rsa_t *rsa, FILE *fp); extern bool rsa_write_pem_private_key(rsa_t *rsa, FILE *fp); diff --git a/src/splay_tree.h b/src/splay_tree.h index 8367ce71..ca8e1b8f 100644 --- a/src/splay_tree.h +++ b/src/splay_tree.h @@ -64,10 +64,10 @@ typedef struct splay_tree_t { /* (De)constructors */ -extern splay_tree_t *splay_alloc_tree(splay_compare_t, splay_action_t); +extern splay_tree_t *splay_alloc_tree(splay_compare_t, splay_action_t) __attribute__ ((__malloc__)); extern void splay_free_tree(splay_tree_t *); -extern splay_node_t *splay_alloc_node(void); +extern splay_node_t *splay_alloc_node(void) __attribute__ ((__malloc__)); extern void splay_free_node(splay_tree_t *tree, splay_node_t *); /* Insertion and deletion */ -- 2.39.5