This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
+ the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "includes.h"
pstring printdb_path;
BOOL done_become_root = False;
- if (printername == NULL)
- return NULL;
+ SMB_ASSERT(printername != NULL);
for (p = print_db_head, last_entry = print_db_head; p; p = p->next) {
/* Ensure the list terminates... JRA. */
/* Not found. */
if (num_open >= MAX_PRINT_DBS_OPEN) {
/* Try and recycle the last entry. */
- DLIST_PROMOTE(print_db_head, last_entry);
+ if (print_db_head && last_entry) {
+ DLIST_PROMOTE(print_db_head, last_entry);
+ }
for (p = print_db_head; p; p = p->next) {
if (p->ref_count)
memset(p->printer_name, '\0', sizeof(p->printer_name));
break;
}
- if (p) {
+ if (p && print_db_head) {
DLIST_PROMOTE(print_db_head, p);
p = print_db_head;
}
if (!p) {
/* Create one. */
- p = (struct tdb_print_db *)malloc(sizeof(struct tdb_print_db));
+ p = SMB_MALLOC_P(struct tdb_print_db);
if (!p) {
DEBUG(0,("get_print_db: malloc fail !\n"));
return NULL;
/* Entry is dead if process doesn't exist or refcount is zero. */
- while ((i < data.dsize) && ((IVAL(data.dptr, i + 4) == 0) || !process_exists(pid))) {
+ while ((i < data.dsize) && ((IVAL(data.dptr, i + 4) == 0) || !process_exists_by_pid(pid))) {
/* Refcount == zero is a logic error and should never happen. */
if (IVAL(data.dptr, i + 4) == 0) {