const struct smb_filename *smb_fname,
const struct timespec *old_write_time)
{
- TALLOC_CTX *frame = talloc_stackframe();
-
struct share_mode_lock *lck;
+ lck = talloc(mem_ctx, struct share_mode_lock);
+ if (lck == NULL) {
+ DEBUG(1, ("talloc failed\n"));
+ return NULL;
+ }
+
if (the_lock == NULL) {
the_lock = get_share_mode_lock_internal(
- frame, id, servicepath, smb_fname, old_write_time);
+ lck, id, servicepath, smb_fname, old_write_time);
if (the_lock == NULL) {
goto fail;
}
talloc_set_destructor(the_lock, the_lock_destructor);
+ } else {
+ if (talloc_reference(lck, the_lock) == NULL) {
+ DEBUG(1, ("talloc_reference failed\n"));
+ goto fail;
+ }
}
if (!file_id_equal(&the_lock->data->id, &id)) {
DEBUG(1, ("Can not lock two share modes simultaneously\n"));
goto fail;
}
- lck = talloc(mem_ctx, struct share_mode_lock);
- if (lck == NULL) {
- DEBUG(1, ("talloc failed\n"));
- goto fail;
- }
- if (talloc_reference(lck, the_lock) == NULL) {
- DEBUG(1, ("talloc_reference failed\n"));
- goto fail;
- }
lck->data = the_lock->data;
- TALLOC_FREE(frame);
return lck;
fail:
- TALLOC_FREE(frame);
+ TALLOC_FREE(lck);
return NULL;
}