summaryrefslogtreecommitdiff
path: root/source3/locking
diff options
context:
space:
mode:
authorSimo Sorce <idra@samba.org>2001-09-17 04:16:35 +0000
committerSimo Sorce <idra@samba.org>2001-09-17 04:16:35 +0000
commit81fdc3c3f76075babe3e1f4bf43ed2cfd5723472 (patch)
tree6ab7772a7668a46791b953e8bbb018358c3d7a14 /source3/locking
parentacc373297159d87849d5e4c48345723c44fc3e95 (diff)
downloadsamba-81fdc3c3f76075babe3e1f4bf43ed2cfd5723472.tar.gz
samba-81fdc3c3f76075babe3e1f4bf43ed2cfd5723472.tar.bz2
samba-81fdc3c3f76075babe3e1f4bf43ed2cfd5723472.zip
move to SAFE_FREE()
(This used to be commit e61aec84edaf55b9ee087b076d2f1311033dc839)
Diffstat (limited to 'source3/locking')
-rw-r--r--source3/locking/brlock.c16
-rw-r--r--source3/locking/locking.c16
-rw-r--r--source3/locking/posix.c38
3 files changed, 31 insertions, 39 deletions
diff --git a/source3/locking/brlock.c b/source3/locking/brlock.c
index 2b21761cb2..b16cc539c8 100644
--- a/source3/locking/brlock.c
+++ b/source3/locking/brlock.c
@@ -347,12 +347,12 @@ NTSTATUS brl_lock(SMB_DEV_T dev, SMB_INO_T ino, int fnum,
tdb_store(tdb, kbuf, dbuf, TDB_REPLACE);
- free(dbuf.dptr);
+ SAFE_FREE(dbuf.dptr);
tdb_chainunlock(tdb, kbuf);
return NT_STATUS_OK;
fail:
- if (dbuf.dptr) free(dbuf.dptr);
+ SAFE_FREE(dbuf.dptr);
tdb_chainunlock(tdb, kbuf);
return status;
}
@@ -411,7 +411,7 @@ BOOL brl_unlock(SMB_DEV_T dev, SMB_INO_T ino, int fnum,
tdb_store(tdb, kbuf, dbuf, TDB_REPLACE);
}
- free(dbuf.dptr);
+ SAFE_FREE(dbuf.dptr);
tdb_chainunlock(tdb, kbuf);
return True;
}
@@ -439,7 +439,7 @@ BOOL brl_unlock(SMB_DEV_T dev, SMB_INO_T ino, int fnum,
tdb_store(tdb, kbuf, dbuf, TDB_REPLACE);
}
- free(dbuf.dptr);
+ SAFE_FREE(dbuf.dptr);
tdb_chainunlock(tdb, kbuf);
return True;
}
@@ -448,7 +448,7 @@ BOOL brl_unlock(SMB_DEV_T dev, SMB_INO_T ino, int fnum,
/* we didn't find it */
fail:
- if (dbuf.dptr) free(dbuf.dptr);
+ SAFE_FREE(dbuf.dptr);
tdb_chainunlock(tdb, kbuf);
return False;
}
@@ -501,12 +501,12 @@ BOOL brl_locktest(SMB_DEV_T dev, SMB_INO_T ino, int fnum,
}
/* no conflicts - we could have added it */
- free(dbuf.dptr);
+ SAFE_FREE(dbuf.dptr);
tdb_chainunlock(tdb, kbuf);
return True;
fail:
- if (dbuf.dptr) free(dbuf.dptr);
+ SAFE_FREE(dbuf.dptr);
tdb_chainunlock(tdb, kbuf);
return False;
}
@@ -559,7 +559,7 @@ void brl_close(SMB_DEV_T dev, SMB_INO_T ino, pid_t pid, int tid, int fnum)
/* we didn't find it */
fail:
- if (dbuf.dptr) free(dbuf.dptr);
+ SAFE_FREE(dbuf.dptr);
tdb_chainunlock(tdb, kbuf);
}
diff --git a/source3/locking/locking.c b/source3/locking/locking.c
index 4092c989d0..750ebe6716 100644
--- a/source3/locking/locking.c
+++ b/source3/locking/locking.c
@@ -436,7 +436,7 @@ int get_share_modes(connection_struct *conn,
ret = data->num_share_mode_entries;
if(ret)
*shares = (share_mode_entry *)memdup(dbuf.dptr + sizeof(*data), ret * sizeof(**shares));
- free(dbuf.dptr);
+ SAFE_FREE(dbuf.dptr);
if (! *shares)
return 0;
@@ -537,7 +537,7 @@ ssize_t del_share_entry( SMB_DEV_T dev, SMB_INO_T inode,
count = -1;
}
}
- free(dbuf.dptr);
+ SAFE_FREE(dbuf.dptr);
return count;
}
@@ -592,7 +592,7 @@ BOOL set_share_mode(files_struct *fsp, uint16 port, uint16 op_type)
dbuf.dsize = size;
if (tdb_store(tdb, locking_key_fsp(fsp), dbuf, TDB_REPLACE) == -1)
ret = False;
- free(p);
+ SAFE_FREE(p);
return ret;
}
@@ -608,12 +608,12 @@ BOOL set_share_mode(files_struct *fsp, uint16 port, uint16 op_type)
fill_share_mode(p + sizeof(*data), fsp, port, op_type);
memcpy(p + sizeof(*data) + sizeof(share_mode_entry), dbuf.dptr + sizeof(*data),
dbuf.dsize - sizeof(*data));
- free(dbuf.dptr);
+ SAFE_FREE(dbuf.dptr);
dbuf.dptr = p;
dbuf.dsize = size;
if (tdb_store(tdb, locking_key_fsp(fsp), dbuf, TDB_REPLACE) == -1)
ret = False;
- free(p);
+ SAFE_FREE(p);
return ret;
}
@@ -658,7 +658,7 @@ static BOOL mod_share_mode( SMB_DEV_T dev, SMB_INO_T inode, share_mode_entry *en
}
}
- free(dbuf.dptr);
+ SAFE_FREE(dbuf.dptr);
return need_store;
}
@@ -748,12 +748,12 @@ BOOL modify_delete_flag( SMB_DEV_T dev, SMB_INO_T inode, BOOL delete_on_close)
/* store it back */
if (data->num_share_mode_entries) {
if (tdb_store(tdb, locking_key(dev,inode), dbuf, TDB_REPLACE)==-1) {
- free(dbuf.dptr);
+ SAFE_FREE(dbuf.dptr);
return False;
}
}
- free(dbuf.dptr);
+ SAFE_FREE(dbuf.dptr);
return True;
}
diff --git a/source3/locking/posix.c b/source3/locking/posix.c
index eb5e4b6460..8fbe2e2fda 100644
--- a/source3/locking/posix.c
+++ b/source3/locking/posix.c
@@ -107,8 +107,7 @@ static BOOL add_fd_to_close_entry(files_struct *fsp)
tp = Realloc(dbuf.dptr, dbuf.dsize + sizeof(int));
if (!tp) {
DEBUG(0,("add_fd_to_close_entry: Realloc fail !\n"));
- if (dbuf.dptr)
- free(dbuf.dptr);
+ SAFE_FREE(dbuf.dptr);
return False;
} else
dbuf.dptr = tp;
@@ -120,7 +119,7 @@ static BOOL add_fd_to_close_entry(files_struct *fsp)
DEBUG(0,("add_fd_to_close_entry: tdb_store fail !\n"));
}
- free(dbuf.dptr);
+ SAFE_FREE(dbuf.dptr);
return True;
}
@@ -240,17 +239,16 @@ int fd_close_posix(struct connection_struct *conn, files_struct *fsp)
*/
if (!add_fd_to_close_entry(fsp)) {
- free((char *)entries);
+ SAFE_FREE(entries);
return False;
}
- free((char *)entries);
+ SAFE_FREE(entries);
fsp->fd = -1;
return 0;
}
- if(entries)
- free((char *)entries);
+ SAFE_FREE(entries);
/*
* No outstanding POSIX locks. Get the pending close fd's
@@ -276,8 +274,7 @@ int fd_close_posix(struct connection_struct *conn, files_struct *fsp)
delete_close_entries(fsp);
}
- if (fd_array)
- free((char *)fd_array);
+ SAFE_FREE(fd_array);
/*
* Finally close the fd associated with this fsp.
@@ -338,13 +335,12 @@ static BOOL delete_posix_lock_entry_by_index(files_struct *fsp, size_t entry)
tdb_store(posix_lock_tdb, kbuf, dbuf, TDB_REPLACE);
}
- free(dbuf.dptr);
+ SAFE_FREE(dbuf.dptr);
return True;
fail:
- if (dbuf.dptr)
- free(dbuf.dptr);
+ SAFE_FREE(dbuf.dptr);
return False;
}
@@ -391,7 +387,7 @@ static BOOL add_posix_lock_entry(files_struct *fsp, SMB_OFF_T start, SMB_OFF_T s
goto fail;
}
- free(dbuf.dptr);
+ SAFE_FREE(dbuf.dptr);
DEBUG(10,("add_posix_lock: File %s: type = %s: start=%.0f size=%.0f: dev=%.0f inode=%.0f\n",
fsp->fsp_name, posix_lock_type_name(lock_type), (double)start, (double)size,
@@ -400,8 +396,7 @@ static BOOL add_posix_lock_entry(files_struct *fsp, SMB_OFF_T start, SMB_OFF_T s
return True;
fail:
- if (dbuf.dptr)
- free(dbuf.dptr);
+ SAFE_FREE(dbuf.dptr);
return False;
}
@@ -499,14 +494,12 @@ static int delete_posix_lock_entry(files_struct *fsp, SMB_OFF_T start, SMB_OFF_T
posix_lock_type_name(pl->lock_type), (double)pl->start, (double)pl->size,
(unsigned int)num_overlapping_records ));
- if (dbuf.dptr)
- free(dbuf.dptr);
+ SAFE_FREE(dbuf.dptr);
return num_overlapping_records;
fail:
- if (dbuf.dptr)
- free(dbuf.dptr);
+ SAFE_FREE(dbuf.dptr);
return -1;
}
@@ -955,8 +948,7 @@ lock: start = %.0f, size = %.0f\n", (double)l_curr->start, (double)l_curr->size,
} /* end for ( l_curr = lhead; l_curr;) */
} /* end for (i=0; i<num_locks && ul_head; i++) */
- if (dbuf.dptr)
- free(dbuf.dptr);
+ SAFE_FREE(dbuf.dptr);
return lhead;
}
@@ -1266,7 +1258,7 @@ void posix_locking_close_file(files_struct *fsp)
/* All locks are ours. */
DEBUG(10,("posix_locking_close_file: file %s has %u outstanding locks, but all on one fd.\n",
fsp->fsp_name, (unsigned int)count ));
- free((char *)entries);
+ SAFE_FREE(entries);
delete_posix_lock_entries(fsp);
return;
}
@@ -1281,7 +1273,7 @@ void posix_locking_close_file(files_struct *fsp)
if (pl->fd == fsp->fd)
release_posix_lock(fsp, (SMB_BIG_UINT)pl->start, (SMB_BIG_UINT)pl->size );
}
- free((char *)entries);
+ SAFE_FREE(entries);
}
/*******************************************************************