diff options
author | Andrew Tridgell <tridge@samba.org> | 2004-12-03 07:20:30 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:06:20 -0500 |
commit | 6e6374cb5bcffb4df8bdb0a83327fff92b61ac84 (patch) | |
tree | fa45bc8c1a7281492f39069e5edd86da6d0c5d4e /source4/libcli | |
parent | e5ce904ddbd6175ba86ed827bf096b76b11b5511 (diff) | |
download | samba-6e6374cb5bcffb4df8bdb0a83327fff92b61ac84.tar.gz samba-6e6374cb5bcffb4df8bdb0a83327fff92b61ac84.tar.xz samba-6e6374cb5bcffb4df8bdb0a83327fff92b61ac84.zip |
r4055: fixed more places to use type safe allocation macros
(This used to be commit eec698254f67365f27b4b7569fa982e22472aca1)
Diffstat (limited to 'source4/libcli')
-rw-r--r-- | source4/libcli/auth/clikrb5.c | 4 | ||||
-rw-r--r-- | source4/libcli/auth/spnego_parse.c | 2 | ||||
-rw-r--r-- | source4/libcli/ldap/ldap.c | 9 | ||||
-rw-r--r-- | source4/libcli/nmblib.c | 4 | ||||
-rw-r--r-- | source4/libcli/raw/raweas.c | 4 | ||||
-rw-r--r-- | source4/libcli/raw/rawnotify.c | 3 |
6 files changed, 12 insertions, 14 deletions
diff --git a/source4/libcli/auth/clikrb5.c b/source4/libcli/auth/clikrb5.c index 48e1f88503..7ad8dd7b6c 100644 --- a/source4/libcli/auth/clikrb5.c +++ b/source4/libcli/auth/clikrb5.c @@ -212,7 +212,7 @@ return -1; } - sa = malloc( sizeof(struct sockaddr) * num_kdcs ); + sa = malloc_array_p(struct sockaddr, num_kdcs); if (!sa) { DEBUG(0, ("krb5_locate_kdc: malloc failed\n")); krb5_krbhst_free(ctx, hnd); @@ -220,7 +220,7 @@ return -1; } - *addr_pp = malloc(sizeof(struct sockaddr) * num_kdcs); + *addr_pp = malloc_array_p(struct sockaddr, num_kdcs); memset(*addr_pp, '\0', sizeof(struct sockaddr) * num_kdcs ); for (i = 0; i < num_kdcs && (rc = krb5_krbhst_next(ctx, hnd, &hinfo) == 0); i++) { diff --git a/source4/libcli/auth/spnego_parse.c b/source4/libcli/auth/spnego_parse.c index 825b0a78d2..2cf38728a9 100644 --- a/source4/libcli/auth/spnego_parse.c +++ b/source4/libcli/auth/spnego_parse.c @@ -49,7 +49,7 @@ static BOOL read_negTokenInit(struct asn1_data *asn1, struct spnego_negTokenInit asn1_start_tag(asn1, ASN1_CONTEXT(0)); asn1_start_tag(asn1, ASN1_SEQUENCE(0)); - token->mechTypes = talloc(NULL, sizeof(*token->mechTypes)); + token->mechTypes = talloc_p(NULL, const char *); for (i = 0; !asn1->has_error && 0 < asn1_tag_remaining(asn1); i++) { token->mechTypes = diff --git a/source4/libcli/ldap/ldap.c b/source4/libcli/ldap/ldap.c index dd689027f9..076d088ee2 100644 --- a/source4/libcli/ldap/ldap.c +++ b/source4/libcli/ldap/ldap.c @@ -130,7 +130,7 @@ static struct ldap_parse_tree *ldap_parse_simple(TALLOC_CTX *mem_ctx, if (val && strchr("()&|", *val)) return NULL; - ret = talloc(mem_ctx, sizeof(*ret)); + ret = talloc_p(mem_ctx, struct ldap_parse_tree); if (!ret) { errno = ENOMEM; return NULL; @@ -157,8 +157,7 @@ static struct ldap_parse_tree *ldap_parse_filterlist(TALLOC_CTX *mem_ctx, { struct ldap_parse_tree *ret, *next; - ret = talloc(mem_ctx, sizeof(*ret)); - + ret = talloc_p(mem_ctx, struct ldap_parse_tree); if (!ret) { errno = ENOMEM; return NULL; @@ -166,7 +165,7 @@ static struct ldap_parse_tree *ldap_parse_filterlist(TALLOC_CTX *mem_ctx, ret->operation = op; ret->u.list.num_elements = 1; - ret->u.list.elements = talloc(mem_ctx, sizeof(*ret->u.list.elements)); + ret->u.list.elements = talloc_p(mem_ctx, struct ldap_parse_tree *); if (!ret->u.list.elements) { errno = ENOMEM; return NULL; @@ -206,7 +205,7 @@ static struct ldap_parse_tree *ldap_parse_not(TALLOC_CTX *mem_ctx, const char *s { struct ldap_parse_tree *ret; - ret = talloc(mem_ctx, sizeof(*ret)); + ret = talloc_p(mem_ctx, struct ldap_parse_tree); if (!ret) { errno = ENOMEM; return NULL; diff --git a/source4/libcli/nmblib.c b/source4/libcli/nmblib.c index 70c6fab8da..0a3f72ba74 100644 --- a/source4/libcli/nmblib.c +++ b/source4/libcli/nmblib.c @@ -333,7 +333,7 @@ static BOOL parse_alloc_res_rec(char *inbuf,int *offset,int length, struct res_rec **recs, int count) { int i; - *recs = (struct res_rec *)malloc(sizeof(**recs)*count); + *recs = malloc_array_p(struct res_rec, count); if (!*recs) return(False); memset((char *)*recs,'\0',sizeof(**recs)*count); @@ -523,7 +523,7 @@ static struct packet_struct *copy_nmb_packet(struct packet_struct *packet) struct nmb_packet *copy_nmb; struct packet_struct *pkt_copy; - if(( pkt_copy = (struct packet_struct *)malloc(sizeof(*packet))) == NULL) + if(( pkt_copy = malloc_p(struct packet_struct)) == NULL) { DEBUG(0,("copy_nmb_packet: malloc fail.\n")); return NULL; diff --git a/source4/libcli/raw/raweas.c b/source4/libcli/raw/raweas.c index 621181841f..027705b381 100644 --- a/source4/libcli/raw/raweas.c +++ b/source4/libcli/raw/raweas.c @@ -174,7 +174,7 @@ NTSTATUS ea_pull_list(const DATA_BLOB *blob, blob2.data = blob->data + ofs; blob2.length = ea_size - ofs; - *eas = talloc_realloc(mem_ctx, *eas, sizeof(**eas) * (n+1)); + *eas = talloc_realloc_p(mem_ctx, *eas, struct ea_struct, n+1); if (! *eas) return NT_STATUS_NO_MEMORY; len = ea_pull_struct(&blob2, mem_ctx, &(*eas)[n]); @@ -219,7 +219,7 @@ NTSTATUS ea_pull_list_chained(const DATA_BLOB *blob, blob2.data = blob->data + ofs + 4; blob2.length = blob->length - (ofs + 4); - *eas = talloc_realloc(mem_ctx, *eas, sizeof(**eas) * (n+1)); + *eas = talloc_realloc_p(mem_ctx, *eas, struct ea_struct, n+1); if (! *eas) return NT_STATUS_NO_MEMORY; len = ea_pull_struct(&blob2, mem_ctx, &(*eas)[n]); diff --git a/source4/libcli/raw/rawnotify.c b/source4/libcli/raw/rawnotify.c index ea5fada1ee..918fb788cb 100644 --- a/source4/libcli/raw/rawnotify.c +++ b/source4/libcli/raw/rawnotify.c @@ -73,8 +73,7 @@ NTSTATUS smb_raw_changenotify_recv(struct smbcli_request *req, } /* allocate array */ - parms->out.changes = talloc(mem_ctx, sizeof(parms->out.changes[0]) * - parms->out.num_changes); + parms->out.changes = talloc_array_p(mem_ctx, struct notify_changes, parms->out.num_changes); if (!parms->out.changes) { return NT_STATUS_NO_MEMORY; } |