diff options
author | Jeremy Allison <jra@samba.org> | 2001-03-02 00:20:43 +0000 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2001-03-02 00:20:43 +0000 |
commit | 74294f5a967cbcdaa4d502bda3b6147d912f8411 (patch) | |
tree | 34bf09b36ef0e0110995aafbf6af748d55c6878e /source3/rpc_server/srv_spoolss_nt.c | |
parent | 1b476b12d914e57a1b46864d0e12c0ba054af949 (diff) | |
download | samba-74294f5a967cbcdaa4d502bda3b6147d912f8411.tar.gz samba-74294f5a967cbcdaa4d502bda3b6147d912f8411.tar.bz2 samba-74294f5a967cbcdaa4d502bda3b6147d912f8411.zip |
Move to talloc controlled NT forms.
Jeremy.
(This used to be commit 3e190e693375c6032dd64bf8dd3c90f90dc4e3b4)
Diffstat (limited to 'source3/rpc_server/srv_spoolss_nt.c')
-rw-r--r-- | source3/rpc_server/srv_spoolss_nt.c | 35 |
1 files changed, 9 insertions, 26 deletions
diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 341117f346..01055f4e71 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -5278,14 +5278,14 @@ uint32 _new_spoolss_enumforms(pipes_struct *p, SPOOL_Q_ENUMFORMS *q_u, SPOOL_R_E DEBUGADD(5,("Offered buffer size [%d]\n", offered)); DEBUGADD(5,("Info level [%d]\n", level)); - *numofforms = get_ntforms(&list); + *numofforms = get_ntforms(p->mem_ctx, &list); DEBUGADD(5,("Number of forms [%d]\n", *numofforms)); if (*numofforms == 0) return ERROR_NO_MORE_ITEMS; switch (level) { case 1: - if ((forms_1=(FORM_1 *)malloc(*numofforms * sizeof(FORM_1))) == NULL) { + if ((forms_1=(FORM_1 *)talloc(p->mem_ctx, *numofforms * sizeof(FORM_1))) == NULL) { *numofforms=0; return ERROR_NOT_ENOUGH_MEMORY; } @@ -5296,8 +5296,6 @@ uint32 _new_spoolss_enumforms(pipes_struct *p, SPOOL_Q_ENUMFORMS *q_u, SPOOL_R_E fill_form_1(&forms_1[i], &list[i]); } - safe_free(list); - /* check the required size. */ for (i=0; i<*numofforms; i++) { DEBUGADD(6,("adding form [%d]'s size\n",i)); @@ -5306,10 +5304,8 @@ uint32 _new_spoolss_enumforms(pipes_struct *p, SPOOL_Q_ENUMFORMS *q_u, SPOOL_R_E *needed=buffer_size; - if (!alloc_buffer_size(buffer, buffer_size)){ - safe_free(forms_1); + if (!alloc_buffer_size(buffer, buffer_size)) return ERROR_INSUFFICIENT_BUFFER; - } /* fill the buffer with the form structures */ for (i=0; i<*numofforms; i++) { @@ -5317,8 +5313,6 @@ uint32 _new_spoolss_enumforms(pipes_struct *p, SPOOL_Q_ENUMFORMS *q_u, SPOOL_R_E new_smb_io_form_1("", buffer, &forms_1[i], 0); } - safe_free(forms_1); - if (*needed > offered) { *numofforms=0; return ERROR_INSUFFICIENT_BUFFER; @@ -5327,10 +5321,8 @@ uint32 _new_spoolss_enumforms(pipes_struct *p, SPOOL_Q_ENUMFORMS *q_u, SPOOL_R_E return NT_STATUS_NO_PROBLEMO; default: - safe_free(list); return ERROR_INVALID_LEVEL; } - } /**************************************************************************** @@ -5361,7 +5353,7 @@ uint32 _spoolss_getform(pipes_struct *p, SPOOL_Q_GETFORM *q_u, SPOOL_R_GETFORM * DEBUGADD(5,("Offered buffer size [%d]\n", offered)); DEBUGADD(5,("Info level [%d]\n", level)); - numofforms = get_ntforms(&list); + numofforms = get_ntforms(p->mem_ctx, &list); DEBUGADD(5,("Number of forms [%d]\n", numofforms)); if (numofforms == 0) @@ -5382,8 +5374,6 @@ uint32 _spoolss_getform(pipes_struct *p, SPOOL_Q_GETFORM *q_u, SPOOL_R_GETFORM * } } - safe_free(list); - /* check the required size. */ *needed=spoolss_size_form_1(&form_1); @@ -5403,7 +5393,6 @@ uint32 _spoolss_getform(pipes_struct *p, SPOOL_Q_GETFORM *q_u, SPOOL_R_GETFORM * return NT_STATUS_NO_PROBLEMO; default: - safe_free(list); return ERROR_INVALID_LEVEL; } } @@ -6181,14 +6170,12 @@ uint32 _spoolss_addform( pipes_struct *p, SPOOL_Q_ADDFORM *q_u, SPOOL_R_ADDFORM return ERROR_INVALID_HANDLE; } - count=get_ntforms(&list); - if(!add_a_form(&list, form, &count)) + count=get_ntforms(p->mem_ctx, &list); + if(!add_a_form(p->mem_ctx, &list, form, &count)) return ERROR_NOT_ENOUGH_MEMORY; write_ntforms(&list, count); - safe_free(list); - - return 0x0; + return NT_STATUS_NOPROBLEMO; } /**************************************************************************** @@ -6211,12 +6198,10 @@ uint32 _spoolss_deleteform( pipes_struct *p, SPOOL_Q_DELETEFORM *q_u, SPOOL_R_DE return ERROR_INVALID_HANDLE; } - count = get_ntforms(&list); + count = get_ntforms(p->mem_ctx, &list); if(!delete_a_form(&list, form_name, &count, &ret)) return ERROR_INVALID_PARAMETER; - safe_free(list); - return ret; } @@ -6240,12 +6225,10 @@ uint32 _spoolss_setform(pipes_struct *p, SPOOL_Q_SETFORM *q_u, SPOOL_R_SETFORM * DEBUG(0,("_spoolss_setform: Invalid handle (%s).\n", OUR_HANDLE(handle))); return ERROR_INVALID_HANDLE; } - count=get_ntforms(&list); + count=get_ntforms(p->mem_ctx, &list); update_a_form(&list, form, count); write_ntforms(&list, count); - safe_free(list); - return 0x0; } |