static int cmd_lookup(const char **cmd_ptr)
{
fstring buf;
- TALLOC_CTX *mem_ctx = talloc(NULL, 0);
+ TALLOC_CTX *mem_ctx = talloc_new(NULL);
NTSTATUS status;
struct dom_sid *sid;
static int cmd_privileges(const char **cmd_ptr)
{
fstring buf;
- TALLOC_CTX *mem_ctx = talloc(NULL, 0);
+ TALLOC_CTX *mem_ctx = talloc_new(NULL);
NTSTATUS status;
struct dom_sid *sid;
struct lsa_RightSet rights;
static int cmd_addprivileges(const char **cmd_ptr)
{
fstring buf;
- TALLOC_CTX *mem_ctx = talloc(NULL, 0);
+ TALLOC_CTX *mem_ctx = talloc_new(NULL);
NTSTATUS status;
struct dom_sid *sid;
struct lsa_RightSet rights;
static int cmd_delprivileges(const char **cmd_ptr)
{
fstring buf;
- TALLOC_CTX *mem_ctx = talloc(NULL, 0);
+ TALLOC_CTX *mem_ctx = talloc_new(NULL);
NTSTATUS status;
struct dom_sid *sid;
struct lsa_RightSet rights;
NTSTATUS samdb_privilege_setup(struct security_token *token)
{
void *samctx;
- TALLOC_CTX *mem_ctx = talloc(token, 0);
+ TALLOC_CTX *mem_ctx = talloc_new(token);
int i;
NTSTATUS status;
{
char *desc;
- desc = (char *)talloc(schema, data->lenght + 1);
+ desc = talloc_array_p(schema, char, data->lenght + 1);
memcpy(desc, data->data, data->lenght);
desc[data->lenght] = '\0';
{
char *desc;
- desc = (char *)talloc(schema, data->lenght + 1);
+ desc = talloc_array_p(schema, char, data->lenght + 1);
memcpy(desc, data->data, data->lenght);
desc[data->lenght] = '\0';
return read_into_buf(sock, &conn->in_buffer);
}
- mem_ctx = talloc(conn, 0);
+ mem_ctx = talloc_new(conn);
if (!mem_ctx) {
DEBUG(0,("no memory\n"));
return False;
return write_from_buf(sock, &conn->out_buffer);
}
- mem_ctx = talloc(conn, 0);
+ mem_ctx = talloc_new(conn);
if (!mem_ctx) {
DEBUG(0,("no memory\n"));
return False;
/* start off with no events */
ZERO_STRUCTP(ev);
- ev->events = talloc(ev, 0);
+ ev->events = talloc_new(ev);
return ev;
}
int ret = 0;
char *newrdn, *p;
const char *parentdn = "";
- TALLOC_CTX *mem_ctx = talloc(lldb, 0);
+ TALLOC_CTX *mem_ctx = talloc_new(lldb);
/* ignore ltdb specials */
if (olddn[0] == '@' ||newdn[0] == '@') {
#define talloc_zero(ctx, size) _talloc_zero(ctx, size, __location__)
#define talloc_realloc(ctx, ptr, size) _talloc_realloc(ctx, ptr, size, __location__)
#define talloc_p(ctx, type) (type *)talloc_named_const(ctx, sizeof(type), #type)
+#define talloc_new(ctx) talloc_named_const(ctx, 0, "talloc_new: " __location__)
#define talloc_zero_p(ctx, type) (type *)_talloc_zero(ctx, sizeof(type), #type)
#define talloc_zero_array_p(ctx, type, count) (type *)talloc_zero_array(ctx, sizeof(type), count, __location__)
#define talloc_array_p(ctx, type, count) (type *)talloc_array(ctx, sizeof(type), count, __location__)
talloc_named(NULL, 0, fmt, ...);
+=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
+void *talloc_new(void *ctx);
+
+This is a utility macro that creates a new memory context hanging
+off an exiting context, automatically naming it "talloc_new: __location__"
+where __location__ is the source line it is called from. It is
+particularly useful for creating a new temporary working context.
+
+
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
void *talloc_realloc(const void *context, void *ptr, size_t size);
printf("TESTING MISCELLANEOUS\n");
- root = talloc(NULL, 0);
+ root = talloc_new(NULL);
p1 = talloc(root, 0x7fffffff);
if (p1) {
printf("TESTING REALLOC\n");
- root = talloc(NULL, 0);
+ root = talloc_new(NULL);
p1 = talloc(root, 10);
CHECK_SIZE(p1, 10);
state.dirlist_len = 0;
state.total_received = 0;
- state.dirlist = talloc(state.mem_ctx, 0);
+ state.dirlist = talloc_new(state.mem_ctx);
mask = talloc_strdup(state.mem_ctx, Mask);
if (level == RAW_SEARCH_GENERIC) {
state.dirlist_len = 0;
state.total_received = 0;
- state.dirlist = talloc(state.mem_ctx, 0);
+ state.dirlist = talloc_new(state.mem_ctx);
mask = talloc_strdup(state.mem_ctx, Mask);
while (1) {
{
struct smb_nttrans nt;
uint8_t *params;
- TALLOC_CTX *mem_ctx = talloc(tree, 0);
+ TALLOC_CTX *mem_ctx = talloc_new(tree);
uint16_t fname_len;
DATA_BLOB sd_blob, ea_blob;
struct smbcli_request *req;
{
struct lsa_RightSet rights;
NTSTATUS status;
- TALLOC_CTX *mem_ctx = talloc(cli, 0);
+ TALLOC_CTX *mem_ctx = talloc_new(cli);
struct dom_sid *sid;
unsigned i;
uint32_t count = 1;
NTSTATUS status;
struct dom_sid *sid;
- TALLOC_CTX *mem_ctx2 = talloc(mem_ctx, 0);
+ TALLOC_CTX *mem_ctx2 = talloc_new(mem_ctx);
status = smblsa_connect(cli);
if (!NT_STATUS_IS_OK(status)) {
uint32_t count = 1;
NTSTATUS status;
struct dom_sid *sid;
- TALLOC_CTX *mem_ctx2 = talloc(mem_ctx, 0);
+ TALLOC_CTX *mem_ctx2 = talloc_new(mem_ctx);
uint32_t rid;
status = smblsa_connect(cli);
TALLOC_CTX *mem_ctx, struct dom_sid **sid)
{
const char *attrs[] = { "objectSid", NULL };
- void *ctx = talloc(mem_ctx, 0);
+ void *ctx = talloc_new(mem_ctx);
const char *sidstr;
int ret;
struct ldb_message **res;
struct dom_sid *domain_sid;
NTSTATUS status;
- ctx = talloc(sidmap, 0);
+ ctx = talloc_new(sidmap);
sidstr = dom_sid_string(ctx, sid);
if (sidstr == NULL) {
talloc_free(ctx);
NTSTATUS status;
struct dom_sid *domain_sid;
- ctx = talloc(sidmap, 0);
+ ctx = talloc_new(sidmap);
sidstr = dom_sid_string(ctx, sid);
if (sidstr == NULL) {
talloc_free(ctx);
*/
- ctx = talloc(sidmap, 0);
+ ctx = talloc_new(sidmap);
/*
*/
- ctx = talloc(sidmap, 0);
+ ctx = talloc_new(sidmap);
/*
{
NTSTATUS status;
struct dom_sid *domain_sid;
- void *ctx = talloc(mem_ctx, 0);
+ void *ctx = talloc_new(mem_ctx);
uint32_t rid;
status = sidmap_primary_domain_sid(sidmap, ctx, &domain_sid);
uint16_t attrib)
{
struct pvfs_filename *name1, *name2;
- TALLOC_CTX *mem_ctx = talloc(req, 0);
+ TALLOC_CTX *mem_ctx = talloc_new(req);
NTSTATUS status;
/* resolve the wildcard pattern for this name */
const char *fname, int fd, const char *attr_name,
void *p, ndr_push_flags_fn_t push_fn)
{
- TALLOC_CTX *mem_ctx = talloc(NULL, 0);
+ TALLOC_CTX *mem_ctx = talloc_new(NULL);
DATA_BLOB blob;
NTSTATUS status;
{
NTSTATUS status;
struct xattr_DosAttrib attrib;
- TALLOC_CTX *mem_ctx = talloc(name, 0);
+ TALLOC_CTX *mem_ctx = talloc_new(name);
struct xattr_DosInfo1 *info1;
struct xattr_DosInfo2 *info2;
return NT_STATUS_OK;
}
- mem_ctx = talloc(pvfs, 0);
+ mem_ctx = talloc_new(pvfs);
status = pull_xattr_blob_tdb(pvfs, mem_ctx, XATTR_LIST_ATTR,
fname, fd, 100, &blob);
*/
NTSTATUS unlink_xattr_tdb(struct pvfs_state *pvfs, const char *fname)
{
- TALLOC_CTX *mem_ctx = talloc(pvfs, 0);
+ TALLOC_CTX *mem_ctx = talloc_new(pvfs);
DATA_BLOB blob;
const char *s;
NTSTATUS status;
{
struct unixuid_private *private = ntvfs->private_data;
struct security_token *token = req->session->session_info->security_token;
- void *ctx = talloc(req, 0);
+ void *ctx = talloc_new(req);
struct unix_sec_ctx *newsec;
NTSTATUS status;
for (i=0;i<torture_numops;i++) {
NTSTATUS status1, status2, status2_p;
int64_t tdif;
- TALLOC_CTX *mem_ctx = talloc(NULL, 0);
+ TALLOC_CTX *mem_ctx = talloc_new(NULL);
enum deny_result res, res2;
int b_sa1 = random() & ((1<<nbits1)-1);
int b_am1 = random() & ((1<<nbits2)-1);
return False;
}
- mem_ctx = talloc(cli, 0);
+ mem_ctx = talloc_new(cli);
printf("Checking DENY_DOS shared handle semantics\n");
smbcli_unlink(cli->tree, fname);
BOOL ret = True;
extern int torture_numops;
int n = torture_numops;
- void *ctx = talloc(NULL, 0);
+ void *ctx = talloc_new(NULL);
idr = idr_init(ctx);
for (t=0;t<ARRAY_SIZE(search_types);t++) {
ZERO_STRUCT(result);
- result.mem_ctx = talloc(mem_ctx, 0);
+ result.mem_ctx = talloc_new(mem_ctx);
printf("Continue %s via %s\n", search_types[t].name, search_types[t].cont_name);
printf("pulling the first file\n");
ZERO_STRUCT(result);
- result.mem_ctx = talloc(mem_ctx, 0);
+ result.mem_ctx = talloc_new(mem_ctx);
io.generic.level = RAW_SEARCH_BOTH_DIRECTORY_INFO;
io.t2ffirst.in.search_attrib = 0;
union smb_fileinfo info;
NTSTATUS status;
struct ea_name ea;
- TALLOC_CTX *mem_ctx = talloc(cli, 0);
+ TALLOC_CTX *mem_ctx = talloc_new(cli);
info.ea_list.level = RAW_FILEINFO_EA_LIST;
info.ea_list.file.fname = fname;