Lines Matching refs:tmp

50   struct msg *tmp;
51 if ((tmp = malloc(sizeof(struct msg))) == NULL) {
55 tmp->base = &msg_base__;
57 tmp->from_name_data = NULL;
58 tmp->from_name_set = 0;
60 tmp->to_name_data = NULL;
61 tmp->to_name_set = 0;
63 tmp->attack_data = NULL;
64 tmp->attack_set = 0;
66 tmp->run_data = NULL;
67 tmp->run_length = 0;
68 tmp->run_num_allocated = 0;
69 tmp->run_set = 0;
71 return (tmp);
136 struct evbuffer *tmp = NULL;
147 if ((tmp = evbuffer_new()) == NULL) {
151 kill_marshal(tmp, value);
152 if (kill_unmarshal(msg->attack_data, tmp) == -1) {
157 evbuffer_free(tmp);
160 if (tmp != NULL)
161 evbuffer_free(tmp);
178 struct evbuffer *tmp = NULL;
180 if ((tmp = evbuffer_new()) == NULL) {
185 run_marshal(tmp, value);
186 if (run_unmarshal(msg->run_data[off], tmp) == -1) {
191 done:if (tmp != NULL)
192 evbuffer_free(tmp);
243 msg_clear(struct msg *tmp)
245 if (tmp->from_name_set == 1) {
246 free(tmp->from_name_data);
247 tmp->from_name_data = NULL;
248 tmp->from_name_set = 0;
250 if (tmp->to_name_set == 1) {
251 free(tmp->to_name_data);
252 tmp->to_name_data = NULL;
253 tmp->to_name_set = 0;
255 if (tmp->attack_set == 1) {
256 kill_free(tmp->attack_data);
257 tmp->attack_data = NULL;
258 tmp->attack_set = 0;
260 if (tmp->run_set == 1) {
262 for (i = 0; i < tmp->run_length; ++i) {
263 run_free(tmp->run_data[i]);
265 free(tmp->run_data);
266 tmp->run_data = NULL;
267 tmp->run_set = 0;
268 tmp->run_length = 0;
269 tmp->run_num_allocated = 0;
274 msg_free(struct msg *tmp)
276 if (tmp->from_name_data != NULL)
277 free (tmp->from_name_data);
278 if (tmp->to_name_data != NULL)
279 free (tmp->to_name_data);
280 if (tmp->attack_data != NULL)
281 kill_free(tmp->attack_data);
282 if (tmp->run_set == 1) {
284 for (i = 0; i < tmp->run_length; ++i) {
285 run_free(tmp->run_data[i]);
287 free(tmp->run_data);
288 tmp->run_data = NULL;
289 tmp->run_set = 0;
290 tmp->run_length = 0;
291 tmp->run_num_allocated = 0;
293 free(tmp->run_data);
294 free(tmp);
298 msg_marshal(struct evbuffer *evbuf, const struct msg *tmp){
299 evtag_marshal_string(evbuf, MSG_FROM_NAME, tmp->from_name_data);
300 evtag_marshal_string(evbuf, MSG_TO_NAME, tmp->to_name_data);
301 if (tmp->attack_set) {
302 evtag_marshal_kill(evbuf, MSG_ATTACK, tmp->attack_data);
304 if (tmp->run_set) {
307 for (i = 0; i < tmp->run_length; ++i) {
308 evtag_marshal_run(evbuf, MSG_RUN, tmp->run_data[i]);
315 msg_unmarshal(struct msg *tmp, struct evbuffer *evbuf)
325 if (tmp->from_name_set)
327 if (evtag_unmarshal_string(evbuf, MSG_FROM_NAME, &tmp->from_name_data) == -1) {
331 tmp->from_name_set = 1;
336 if (tmp->to_name_set)
338 if (evtag_unmarshal_string(evbuf, MSG_TO_NAME, &tmp->to_name_data) == -1) {
342 tmp->to_name_set = 1;
347 if (tmp->attack_set)
349 tmp->attack_data = kill_new();
350 if (tmp->attack_data == NULL)
352 if (evtag_unmarshal_kill(evbuf, MSG_ATTACK, tmp->attack_data) == -1) {
356 tmp->attack_set = 1;
361 if (tmp->run_length >= tmp->run_num_allocated &&
362 msg_run_expand_to_hold_more(tmp) < 0) {
366 tmp->run_data[tmp->run_length] = run_new();
367 if (tmp->run_data[tmp->run_length] == NULL)
369 if (evtag_unmarshal_run(evbuf, MSG_RUN, tmp->run_data[tmp->run_length]) == -1) {
373 ++tmp->run_length;
374 tmp->run_set = 1;
382 if (msg_complete(tmp) == -1)
412 struct evbuffer *tmp = evbuffer_new();
414 if (evtag_unmarshal(evbuf, &tag, tmp) == -1 || tag != need_tag)
417 if (msg_unmarshal(msg, tmp) == -1)
423 evbuffer_free(tmp);
460 struct kill *tmp;
461 if ((tmp = malloc(sizeof(struct kill))) == NULL) {
465 tmp->base = &kill_base__;
467 tmp->weapon_data = NULL;
468 tmp->weapon_set = 0;
470 tmp->action_data = NULL;
471 tmp->action_set = 0;
473 tmp->how_often_data = NULL;
474 tmp->how_often_length = 0;
475 tmp->how_often_num_allocated = 0;
476 tmp->how_often_set = 0;
478 return (tmp);
578 kill_clear(struct kill *tmp)
580 if (tmp->weapon_set == 1) {
581 free(tmp->weapon_data);
582 tmp->weapon_data = NULL;
583 tmp->weapon_set = 0;
585 if (tmp->action_set == 1) {
586 free(tmp->action_data);
587 tmp->action_data = NULL;
588 tmp->action_set = 0;
590 if (tmp->how_often_set == 1) {
591 free(tmp->how_often_data);
592 tmp->how_often_data = NULL;
593 tmp->how_often_set = 0;
594 tmp->how_often_length = 0;
595 tmp->how_often_num_allocated = 0;
600 kill_free(struct kill *tmp)
602 if (tmp->weapon_data != NULL)
603 free (tmp->weapon_data);
604 if (tmp->action_data != NULL)
605 free (tmp->action_data);
606 if (tmp->how_often_set == 1) {
607 free(tmp->how_often_data);
608 tmp->how_often_data = NULL;
609 tmp->how_often_set = 0;
610 tmp->how_often_length = 0;
611 tmp->how_often_num_allocated = 0;
613 free(tmp->how_often_data);
614 free(tmp);
618 kill_marshal(struct evbuffer *evbuf, const struct kill *tmp){
619 evtag_marshal_string(evbuf, KILL_WEAPON, tmp->weapon_data);
620 evtag_marshal_string(evbuf, KILL_ACTION, tmp->action_data);
621 if (tmp->how_often_set) {
624 for (i = 0; i < tmp->how_often_length; ++i) {
625 evtag_marshal_int(evbuf, KILL_HOW_OFTEN, tmp->how_often_data[i]);
632 kill_unmarshal(struct kill *tmp, struct evbuffer *evbuf)
642 if (tmp->weapon_set)
644 if (evtag_unmarshal_string(evbuf, KILL_WEAPON, &tmp->weapon_data) == -1) {
648 tmp->weapon_set = 1;
653 if (tmp->action_set)
655 if (evtag_unmarshal_string(evbuf, KILL_ACTION, &tmp->action_data) == -1) {
659 tmp->action_set = 1;
664 if (tmp->how_often_length >= tmp->how_often_num_allocated &&
665 kill_how_often_expand_to_hold_more(tmp) < 0) {
669 if (evtag_unmarshal_int(evbuf, KILL_HOW_OFTEN, &tmp->how_often_data[tmp->how_often_length]) == -1) {
673 ++tmp->how_often_length;
674 tmp->how_often_set = 1;
682 if (kill_complete(tmp) == -1)
703 struct evbuffer *tmp = evbuffer_new();
705 if (evtag_unmarshal(evbuf, &tag, tmp) == -1 || tag != need_tag)
708 if (kill_unmarshal(msg, tmp) == -1)
714 evbuffer_free(tmp);
758 struct run *tmp;
759 if ((tmp = malloc(sizeof(struct run))) == NULL) {
763 tmp->base = &run_base__;
765 tmp->how_data = NULL;
766 tmp->how_set = 0;
768 tmp->some_bytes_data = NULL;
769 tmp->some_bytes_length = 0;
770 tmp->some_bytes_set = 0;
772 memset(tmp->fixed_bytes_data, 0, sizeof(tmp->fixed_bytes_data));
773 tmp->fixed_bytes_set = 0;
775 tmp->notes_data = NULL;
776 tmp->notes_length = 0;
777 tmp->notes_num_allocated = 0;
778 tmp->notes_set = 0;
780 tmp->large_number_data = 0;
781 tmp->large_number_set = 0;
783 tmp->other_numbers_data = NULL;
784 tmp->other_numbers_length = 0;
785 tmp->other_numbers_num_allocated = 0;
786 tmp->other_numbers_set = 0;
788 return (tmp);
992 run_clear(struct run *tmp)
994 if (tmp->how_set == 1) {
995 free(tmp->how_data);
996 tmp->how_data = NULL;
997 tmp->how_set = 0;
999 if (tmp->some_bytes_set == 1) {
1000 free (tmp->some_bytes_data);
1001 tmp->some_bytes_data = NULL;
1002 tmp->some_bytes_length = 0;
1003 tmp->some_bytes_set = 0;
1005 tmp->fixed_bytes_set = 0;
1006 memset(tmp->fixed_bytes_data, 0, sizeof(tmp->fixed_bytes_data));
1007 if (tmp->notes_set == 1) {
1009 for (i = 0; i < tmp->notes_length; ++i) {
1010 if (tmp->notes_data[i] != NULL) free(tmp->notes_data[i]);
1012 free(tmp->notes_data);
1013 tmp->notes_data = NULL;
1014 tmp->notes_set = 0;
1015 tmp->notes_length = 0;
1016 tmp->notes_num_allocated = 0;
1018 tmp->large_number_set = 0;
1019 if (tmp->other_numbers_set == 1) {
1020 free(tmp->other_numbers_data);
1021 tmp->other_numbers_data = NULL;
1022 tmp->other_numbers_set = 0;
1023 tmp->other_numbers_length = 0;
1024 tmp->other_numbers_num_allocated = 0;
1029 run_free(struct run *tmp)
1031 if (tmp->how_data != NULL)
1032 free (tmp->how_data);
1033 if (tmp->some_bytes_data != NULL)
1034 free(tmp->some_bytes_data);
1035 if (tmp->notes_set == 1) {
1037 for (i = 0; i < tmp->notes_length; ++i) {
1038 if (tmp->notes_data[i] != NULL) free(tmp->notes_data[i]);
1040 free(tmp->notes_data);
1041 tmp->notes_data = NULL;
1042 tmp->notes_set = 0;
1043 tmp->notes_length = 0;
1044 tmp->notes_num_allocated = 0;
1046 free(tmp->notes_data);
1047 if (tmp->other_numbers_set == 1) {
1048 free(tmp->other_numbers_data);
1049 tmp->other_numbers_data = NULL;
1050 tmp->other_numbers_set = 0;
1051 tmp->other_numbers_length = 0;
1052 tmp->other_numbers_num_allocated = 0;
1054 free(tmp->other_numbers_data);
1055 free(tmp);
1059 run_marshal(struct evbuffer *evbuf, const struct run *tmp){
1060 evtag_marshal_string(evbuf, RUN_HOW, tmp->how_data);
1061 if (tmp->some_bytes_set) {
1062 evtag_marshal(evbuf, RUN_SOME_BYTES, tmp->some_bytes_data, tmp->some_bytes_length);
1064 evtag_marshal(evbuf, RUN_FIXED_BYTES, tmp->fixed_bytes_data, (24));
1065 if (tmp->notes_set) {
1068 for (i = 0; i < tmp->notes_length; ++i) {
1069 evtag_marshal_string(evbuf, RUN_NOTES, tmp->notes_data[i]);
1073 if (tmp->large_number_set) {
1074 evtag_marshal_int64(evbuf, RUN_LARGE_NUMBER, tmp->large_number_data);
1076 if (tmp->other_numbers_set) {
1079 for (i = 0; i < tmp->other_numbers_length; ++i) {
1080 evtag_marshal_int(evbuf, RUN_OTHER_NUMBERS, tmp->other_numbers_data[i]);
1087 run_unmarshal(struct run *tmp, struct evbuffer *evbuf)
1097 if (tmp->how_set)
1099 if (evtag_unmarshal_string(evbuf, RUN_HOW, &tmp->how_data) == -1) {
1103 tmp->how_set = 1;
1108 if (tmp->some_bytes_set)
1110 if (evtag_payload_length(evbuf, &tmp->some_bytes_length) == -1)
1112 if (tmp->some_bytes_length > evbuffer_get_length(evbuf))
1114 if ((tmp->some_bytes_data = malloc(tmp->some_bytes_length)) == NULL)
1116 if (evtag_unmarshal_fixed(evbuf, RUN_SOME_BYTES, tmp->some_bytes_data, tmp->some_bytes_length) == -1) {
1120 tmp->some_bytes_set = 1;
1125 if (tmp->fixed_bytes_set)
1127 if (evtag_unmarshal_fixed(evbuf, RUN_FIXED_BYTES, tmp->fixed_bytes_data, (24)) == -1) {
1131 tmp->fixed_bytes_set = 1;
1136 if (tmp->notes_length >= tmp->notes_num_allocated &&
1137 run_notes_expand_to_hold_more(tmp) < 0) {
1141 if (evtag_unmarshal_string(evbuf, RUN_NOTES, &tmp->notes_data[tmp->notes_length]) == -1) {
1145 ++tmp->notes_length;
1146 tmp->notes_set = 1;
1151 if (tmp->large_number_set)
1153 if (evtag_unmarshal_int64(evbuf, RUN_LARGE_NUMBER, &tmp->large_number_data) == -1) {
1157 tmp->large_number_set = 1;
1162 if (tmp->other_numbers_length >= tmp->other_numbers_num_allocated &&
1163 run_other_numbers_expand_to_hold_more(tmp) < 0) {
1167 if (evtag_unmarshal_int(evbuf, RUN_OTHER_NUMBERS, &tmp->other_numbers_data[tmp->other_numbers_length]) == -1) {
1171 ++tmp->other_numbers_length;
1172 tmp->other_numbers_set = 1;
1180 if (run_complete(tmp) == -1)
1201 struct evbuffer *tmp = evbuffer_new();
1203 if (evtag_unmarshal(evbuf, &tag, tmp) == -1 || tag != need_tag)
1206 if (run_unmarshal(msg, tmp) == -1)
1212 evbuffer_free(tmp);