Don't use 0 as null pointer constant, part 1

Use NULL instead of 0, for clarity.  Except in pointer comparisons;
leave that to the next two commits.
This commit is contained in:
Markus Armbruster 2009-03-22 18:50:43 +01:00
parent a2ed975ec2
commit 615681ce16
51 changed files with 107 additions and 100 deletions

View file

@ -295,7 +295,7 @@ sam_intercept(struct emp_qelem *att_list, struct emp_qelem *def_list,
&& pp->pln_radius < mapdist(x, y, pp->pln_opx, pp->pln_opy))
continue;
if (CANT_HAPPEN(pp->pln_flags & PLN_LAUNCHED)
|| mission_pln_equip(dplp, 0, P_F, 0) < 0) {
|| mission_pln_equip(dplp, NULL, P_F, 0) < 0) {
emp_remque(dqp);
free(dqp);
continue;
@ -369,7 +369,7 @@ ac_intercept(struct emp_qelem *bomb_list, struct emp_qelem *esc_list,
&& pp->pln_radius < mapdist(x, y, pp->pln_opx, pp->pln_opy))
continue;
if (CANT_HAPPEN(pp->pln_flags & PLN_LAUNCHED)
|| mission_pln_equip(plp, 0, P_F, 0) < 0) {
|| mission_pln_equip(plp, NULL, P_F, 0) < 0) {
emp_remque(qp);
free(qp);
continue;

View file

@ -912,7 +912,7 @@ ask_off(int combat_mode, struct combat *off, struct combat *def)
sprintf(prompt, "Number of mil from %s (max %d) : ",
prcom(0, off), mob_support);
}
if ((attacking_mil = onearg(0, prompt)) < 0)
if ((attacking_mil = onearg(NULL, prompt)) < 0)
abort_attack();
if (att_abort(combat_mode, off, def))
return 0;
@ -1271,7 +1271,8 @@ get_ototal(int combat_mode, struct combat *off, struct emp_qelem *olist,
for (qp = olist->q_forw; qp != olist; qp = next) {
next = qp->q_forw;
llp = (struct ulist *)qp;
if (check && !get_land(combat_mode, 0, llp->unit.land.lnd_uid, llp, 0))
if (check &&
!get_land(combat_mode, NULL, llp->unit.land.lnd_uid, llp, 0))
continue;
if (combat_mode == A_ATTACK) {
w = -1;
@ -1448,7 +1449,7 @@ put_land(struct emp_qelem *list)
emp_remque((struct emp_qelem *)llp);
free(llp);
} else
get_land(A_ATTACK, 0, llp->unit.land.lnd_uid, llp, 0);
get_land(A_ATTACK, NULL, llp->unit.land.lnd_uid, llp, 0);
}
}
@ -2181,7 +2182,7 @@ take_def(int combat_mode, struct emp_qelem *list, struct combat *off,
{
int n;
int occuppied = 0;
struct ulist *llp, *delete_me = 0;
struct ulist *llp, *delete_me = NULL;
char buf[1024];
struct sctstr sect;
struct shpstr ship;

View file

@ -48,7 +48,7 @@ getstarg(char *input, char *prompt, char *buf)
*buf = '\0';
if (input == 0 || *input == 0) {
if (getstring(prompt, buf) == 0)
return 0;
return NULL;
} else {
strcpy(buf, input);
}

View file

@ -254,7 +254,7 @@ adj_units(coord x, coord y, natid own)
for (i = DIR_FIRST; i <= DIR_LAST; i++) {
getsect(x + diroff[i][0], y + diroff[i][1], &sect);
if (has_units(sect.sct_x, sect.sct_y, own, 0))
if (has_units(sect.sct_x, sect.sct_y, own, NULL))
return 1;
}
return 0;

View file

@ -989,7 +989,7 @@ lnd_mar_one_sector(struct emp_qelem *list, int dir, natid actor,
pr("%s was shot and killed.\n", prland(&llp->unit.land));
llp->unit.land.lnd_effic = 0;
putland(llp->unit.land.lnd_uid, &llp->unit.land);
lnd_delete(llp, 0);
lnd_delete(llp, NULL);
}
}
}

View file

@ -610,12 +610,12 @@ perform_mission(coord x, coord y, natid victim, struct emp_qelem *list,
/* Split off the escorts at this base into e */
divide(&escorts, &e, air->x, air->y);
mission_pln_arm(&b, air->x, air->y, 2 * md, 'p', 0, 0);
mission_pln_arm(&b, air->x, air->y, 2 * md, 'p', NULL, 0);
if (QEMPTY(&b))
continue;
mission_pln_arm(&e, air->x, air->y, 2 * md, 'p', 0, P_F | P_ESC);
mission_pln_arm(&e, air->x, air->y, 2 * md, 'p', NULL, P_F | P_ESC);
pp = BestAirPath(buf, air->x, air->y, x, y);
if (CANT_HAPPEN(!pp))

View file

@ -61,7 +61,7 @@ msl_equip(struct plnstr *pp, char mission)
memset(&pl, 0, sizeof(struct plist));
pl.pcp = plchr + pp->pln_type;
pl.plane = *pp;
return mission_pln_equip(&pl, 0, 0, mission);
return mission_pln_equip(&pl, NULL, 0, mission);
}
int
@ -271,7 +271,7 @@ msl_intercept(coord x, coord y, natid bombown, int hardtarget,
if (pp->pln_own != sect.sct_own)
continue;
pcp = ip->pcp;
if (mission_pln_equip(ip, 0, 0, 'i') < 0) {
if (mission_pln_equip(ip, NULL, 0, 'i') < 0) {
emp_remque(qp);
free(qp);
continue;
@ -290,7 +290,7 @@ msl_intercept(coord x, coord y, natid bombown, int hardtarget,
ip = (struct plist *)qp;
pp = &ip->plane;
pcp = ip->pcp;
if (mission_pln_equip(ip, 0, 0, 'i') < 0) {
if (mission_pln_equip(ip, NULL, 0, 'i') < 0) {
emp_remque(qp);
free(qp);
continue;
@ -401,7 +401,7 @@ msl_launch_mindam(struct emp_qelem *list, coord x, coord y, int hardtarget,
next = qp->q_back;
plp = (struct plist *)qp;
if (mission_pln_equip(plp, 0, 0, 'p') >= 0) {
if (mission_pln_equip(plp, NULL, 0, 'p') >= 0) {
if (msl_hit(&plp->plane,
hardtarget, type, news_item, snews_item,
whatp, x, y, victim)) {

View file

@ -201,7 +201,7 @@ pr_wall(char *format, ...)
va_start(ap, format);
(void)vsprintf(buf + n, format, ap);
va_end(ap);
for (p = player_next(0); p; p = player_next(p)) {
for (p = player_next(NULL); p; p = player_next(p)) {
if (p->state != PS_PLAYING)
continue;
pr_player(p, C_FLASH, buf);

View file

@ -52,7 +52,7 @@ setrel(natid us, natid them, int rel)
char *whichway;
int n_up = 0;
int n_down = 0;
char *addendum = 0;
char *addendum = NULL;
int theirrel;
if (rel < AT_WAR)

View file

@ -423,7 +423,7 @@ most_valuable_ship(struct emp_qelem *list)
struct emp_qelem *qp;
struct emp_qelem *next;
struct ulist *mlp;
struct ulist *mvs = 0;
struct ulist *mvs = NULL;
for (qp = list->q_back; qp != list; qp = next) {
next = qp->q_back;

View file

@ -147,14 +147,14 @@ unit_path(int together, struct empobj *unit, char *buf)
return NULL;
if (!sarg_xy(buf, &destx, &desty))
return 0;
return NULL;
if (!together) {
pr("Cannot go to a destination sector if not all starting in the same sector\n");
return 0;
return NULL;
}
if (!getsect(destx, desty, &d_sect)) {
pr("%d,%d is not a sector\n", destx, desty);
return 0;
return NULL;
}
if (unit->ef_type == EF_SHIP) {
cp = BestShipPath(buf, unit->x, unit->y,
@ -162,7 +162,7 @@ unit_path(int together, struct empobj *unit, char *buf)
if (!cp || unit->mobil <= 0) {
pr("Can't get to '%s' right now.\n",
xyas(d_sect.sct_x, d_sect.sct_y, player->cnum));
return 0;
return NULL;
}
} else {
getsect(unit->x, unit->y, &sect);
@ -173,7 +173,7 @@ unit_path(int together, struct empobj *unit, char *buf)
mtype == MOB_RAIL ? "railway" : "path",
xyas(unit->x, unit->y, player->cnum),
xyas(d_sect.sct_x, d_sect.sct_y, player->cnum));
return 0;
return NULL;
}
pr("Using path '%s'\n", cp);
}

View file

@ -49,7 +49,7 @@ whatitem(char *input, char *prompt)
p = getstarg(input, prompt, buf);
if (p == 0 || *p == 0)
return 0;
return NULL;
ip = item_by_name(p);
if (!ip)
pr("Unrecognized item \"%c\"\n", *p);
@ -69,5 +69,5 @@ item_by_name(char *str)
if (*str == ip->i_mnem)
return ip;
}
return 0;
return NULL;
}