MCPcopy Create free account
hub / github.com/ObEngine/ObEngine / gz_error

Function gz_error

extlibs/minizip/src/gzlib.c:617–659  ·  view source on GitHub ↗

Create an error message in allocated memory and set state->err and state->msg accordingly. Free any previous error message already there. Do not try to free or allocate space if the error is Z_MEM_ERROR (out of memory). Simply save the error message as a static string. If there is an allocation failure constructing the error message, then convert the error to out of memory. */

(state, err, msg)

Source from the content-addressed store, hash-verified

615 allocation failure constructing the error message, then convert the error to
616 out of memory. */
617void ZLIB_INTERNAL gz_error(state, err, msg)
618gz_statep state;
619int err;
620
621const char* msg;
622{
623 /* free previously allocated message and clear */
624 if (state->msg != NULL)
625 {
626 if (state->err != Z_MEM_ERROR)
627 free(state->msg);
628 state->msg = NULL;
629 }
630
631 /* if fatal, set state->x.have to 0 so that the gzgetc() macro fails */
632 if (err != Z_OK && err != Z_BUF_ERROR)
633 state->x.have = 0;
634
635 /* set error code, and if no message, then done */
636 state->err = err;
637 if (msg == NULL)
638 return;
639
640 /* for an out of memory error, return literal string when requested */
641 if (err == Z_MEM_ERROR)
642 return;
643
644 /* construct error message with path */
645 if ((state->msg = (char *)malloc(strlen(state->path) + strlen(msg) + 3)) ==
646 NULL)
647 {
648 state->err = Z_MEM_ERROR;
649 return;
650 }
651#if !defined(NO_snprintf) && !defined(NO_vsnprintf)
652 (void)snprintf(state->msg, strlen(state->path) + strlen(msg) + 3,
653 "%s%s%s", state->path, ": ", msg);
654#else
655 strcpy(state->msg, state->path);
656 strcat(state->msg, ": ");
657 strcat(state->msg, msg);
658#endif
659}
660
661#ifndef INT_MAX
662/* portably return maximum value for an int (when limits.h presumed not

Callers 15

gz_loadFunction · 0.85
gz_lookFunction · 0.85
gz_decompFunction · 0.85
gzreadFunction · 0.85
gzfreadFunction · 0.85
gzungetcFunction · 0.85
gzclose_rFunction · 0.85
gz_initFunction · 0.85
gz_compFunction · 0.85
gzwriteFunction · 0.85
gzfwriteFunction · 0.85
gzclose_wFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected