r6640: Attempt to fix 'make everything' with the paranoid malloc checker.
authorVolker Lendecke <vlendec@samba.org>
Sat, 7 May 2005 06:59:00 +0000 (06:59 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 15:56:49 +0000 (10:56 -0500)
Volker
(This used to be commit 3db2799822da3711b47b60ba13daa07205ced45f)

source3/torture/cmd_vfs.c
source3/torture/locktest.c
source3/torture/locktest2.c
source3/torture/nbio.c
source3/torture/nsstest.c
source3/torture/vfstest.c
source3/utils/log2pcaphex.c

index f8eb56c50a09ec30e4100590e3238e3a0d9323aa..132e0776aba8d5478d37c2339460f87aecc7234e 100644 (file)
@@ -284,7 +284,7 @@ static NTSTATUS cmd_open(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, c
                return NT_STATUS_UNSUCCESSFUL;
        }
 
-       vfs->files[fd] = (struct files_struct *)malloc(sizeof(struct files_struct));
+       vfs->files[fd] = SMB_MALLOC_P(struct files_struct);
        vfs->files[fd]->fsp_name = SMB_STRDUP(argv[1]);
        vfs->files[fd]->fd = fd;
        vfs->files[fd]->conn = vfs->conn;
index 86379bf3b6dd1c64fac9903487978d6278a2bf08..cdeebf2f8ec36b35225becf649706896feb3bb45 100644 (file)
@@ -423,7 +423,7 @@ static void test_locks(char *share[NSERVERS])
        ZERO_STRUCT(fnum);
        ZERO_STRUCT(cli);
 
-       recorded = (struct record *)malloc(sizeof(*recorded) * numops);
+       recorded = SMB_MALLOC_ARRAY(struct record, numops);
 
        for (n=0; n<numops; n++) {
 #if PRESETS
index 5fbaf9ec584ed8a1259206abc7b6102c0a2f1002..45c0890dc3d0dd4dda3861627de7054c546f1d1c 100644 (file)
@@ -373,7 +373,7 @@ static void test_locks(char *share1, char *share2, char *nfspath1, char *nfspath
        ZERO_STRUCT(fnum);
        ZERO_STRUCT(cli);
 
-       recorded = (struct record *)malloc(sizeof(*recorded) * numops);
+       recorded = SMB_MALLOC_ARRAY(struct record, numops);
 
        for (n=0; n<numops; n++) {
                recorded[n].conn = random() % NCONNECTIONS;
index e6a87e68ad5e76693b7765bbe68fd44c6a564b20..4d61fa053122ca087ea5042b3d07968c7aa10da3 100644 (file)
@@ -281,7 +281,7 @@ static void delete_fn(const char *mnt, file_info *finfo, const char *name, void
        char *s, *n;
        if (finfo->name[0] == '.') return;
 
-       n = strdup(name);
+       n = SMB_STRDUP(name);
        n[strlen(n)-1] = 0;
        asprintf(&s, "%s%s", n, finfo->name);
        if (finfo->mode & aDIR) {
index a803cd7e719e9585968e55a4af58b2f5817df665..585a592bdcd2185b518a8fb88a63f4bd541c4022 100644 (file)
@@ -167,13 +167,13 @@ static struct group *nss_getgrent(void)
                return NULL;
 
        if (!buf) 
-               buf = malloc(buflen);
+               buf = SMB_MALLOC(buflen);
 
 again: 
        status = _nss_getgrent_r(&grp, buf, buflen, &nss_errno);
        if (status == NSS_STATUS_TRYAGAIN) {
                buflen *= 2;
-               buf = realloc(buf, buflen);
+               buf = SMB_REALLOC(buf, buflen);
                goto again;
        }
        if (status == NSS_STATUS_NOTFOUND) {
@@ -199,12 +199,12 @@ static struct group *nss_getgrnam(const char *name)
                return NULL;
 
        if (!buf) 
-               buf = malloc(buflen);
+               buf = SMB_MALLOC(buflen);
 again: 
        status = _nss_getgrnam_r(name, &grp, buf, buflen, &nss_errno);
        if (status == NSS_STATUS_TRYAGAIN) {
                buflen *= 2;
-               buf = realloc(buf, buflen);
+               buf = SMB_REALLOC(buf, buflen);
                goto again;
        }
        if (status == NSS_STATUS_NOTFOUND) {
@@ -230,13 +230,13 @@ static struct group *nss_getgrgid(gid_t gid)
                return NULL;
 
        if (!buf) 
-               buf = malloc(buflen);
+               buf = SMB_MALLOC(buflen);
 
 again: 
        status = _nss_getgrgid_r(gid, &grp, buf, buflen, &nss_errno);
        if (status == NSS_STATUS_TRYAGAIN) {
                buflen *= 2;
-               buf = realloc(buf, buflen);
+               buf = SMB_REALLOC(buf, buflen);
                goto again;
        }
        if (status == NSS_STATUS_NOTFOUND) {
@@ -333,7 +333,7 @@ static void nss_test_initgroups(char *name, gid_t gid)
        int i;
        NSS_STATUS status;
 
-       groups = (gid_t *)malloc(size * sizeof(gid_t));
+       groups = SMB_MALLOC_ARRAY(gid_t, size);
        groups[0] = gid;
 
        status = nss_initgroups(name, gid, &groups, &start, &size);
index 3296a6609605fac27b9067c7a39570b5e3e56fb4..69acd01c1a42be54bc6e4fdfcf7f839fba847b37 100644 (file)
@@ -52,10 +52,10 @@ static char **completion_fn(char *text, int start, int end)
        if (!commands) 
                return NULL;
 
-       matches = (char **)malloc(sizeof(matches[0])*MAX_COMPLETIONS);
+       matches = SMB_MALLOC_ARRAY(char *, MAX_COMPLETIONS);
        if (!matches) return NULL;
 
-       matches[count++] = strdup(text);
+       matches[count++] = SMB_STRDUP(text);
        if (!matches[0]) return NULL;
 
        while (commands && count < MAX_COMPLETIONS-1) 
@@ -68,7 +68,7 @@ static char **completion_fn(char *text, int start, int end)
                        if ((strncmp(text, commands->cmd_set[i].name, strlen(text)) == 0) &&
                                commands->cmd_set[i].fn) 
                        {
-                               matches[count] = strdup(commands->cmd_set[i].name);
+                               matches[count] = SMB_STRDUP(commands->cmd_set[i].name);
                                if (!matches[count]) 
                                        return NULL;
                                count++;
@@ -81,7 +81,7 @@ static char **completion_fn(char *text, int start, int end)
 
        if (count == 2) {
                SAFE_FREE(matches[0]);
-               matches[0] = strdup(matches[1]);
+               matches[0] = SMB_STRDUP(matches[1]);
        }
        matches[count] = NULL;
        return matches;
@@ -248,7 +248,7 @@ static void add_command_set(struct cmd_set *cmd_set)
 {
        struct cmd_list *entry;
 
-       if (!(entry = (struct cmd_list *)malloc(sizeof(struct cmd_list)))) {
+       if (!(entry = SMB_MALLOC_P(struct cmd_list))) {
                DEBUG(0, ("out of memory\n"));
                return;
        }
@@ -274,7 +274,7 @@ static NTSTATUS do_cmd(struct vfs_state *vfs, struct cmd_set *cmd_entry, char *c
  again:
        while(next_token(&p, buf, " ", sizeof(buf))) {
                if (argv) {
-                       argv[argc] = strdup(buf);
+                       argv[argc] = SMB_STRDUP(buf);
                }
                
                argc++;
@@ -284,7 +284,7 @@ static NTSTATUS do_cmd(struct vfs_state *vfs, struct cmd_set *cmd_entry, char *c
 
                /* Create argument list */
 
-               argv = (char **)malloc(sizeof(char *) * argc);
+               argv = SMB_MALLOC_ARRAY(char *, argc);
                memset(argv, 0, sizeof(char *) * argc);
 
                if (!argv) {
index 4804b993382e4098612315e994990114e0b4e808..d07dc2a2115dd86cd0dce72509323a9e3fe202b2 100644 (file)
 */
 
 #include "includes.h"
+
+/* We don't care about the paranoid malloc checker in this standalone
+   program */
+#undef malloc
+
 #include <assert.h>
 
 int quiet = 0;