queueing done

This commit is contained in:
Ellen Arvidsson 2025-04-11 23:37:06 +02:00
parent 7a245f05cb
commit 80ee17692a
6 changed files with 32 additions and 37 deletions

View file

@ -1,15 +1,18 @@
#include <sys/queue.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "spho/err.h"
#include "spho/ctx.h"
static const char *spho_ctx_sys_strerror(struct spho_ctx *);
static const char *spho_ctx_intern_strerror(struct spho_ctx *);
struct spho_err {
int num;
char *msg;
int err;
const char *msg;
};
struct spho_err spho_errmsgs[] = {
@ -43,15 +46,15 @@ spho_ctx_destroy(struct spho_ctx *ctx)
SPHO_PRECOND(ctx != NULL);
while (! SLIST_EMPTY(&c->noms)) {
nom = SLIST_FIRST(&c->noms);
SLIST_REMOVE_HEAD(&c->noms, next);
while (! SLIST_EMPTY(&ctx->noms)) {
nom = SLIST_FIRST(&ctx->noms);
SLIST_REMOVE_HEAD(&ctx->noms, next);
free(nom);
}
while (! SLIST_EMPTY(&c->cnsts)) {
cnst = SLIST_FIRST(&c->cnsts);
SLIST_REMOVE_HEAD(&c->cnsts, next);
while (! SLIST_EMPTY(&ctx->cnsts)) {
cnst = SLIST_FIRST(&ctx->cnsts);
SLIST_REMOVE_HEAD(&ctx->cnsts, next);
free(cnst);
}
}
@ -60,8 +63,8 @@ spho_ctx_destroy(struct spho_ctx *ctx)
const char *
spho_ctx_strerror(struct spho_ctx *ctx)
{
char *msg;
int res;
const char *msg;
SPHO_PRECOND(ctx != NULL);
@ -81,6 +84,10 @@ spho_ctx_strerror(struct spho_ctx *ctx)
static const char *
spho_ctx_sys_strerror(struct spho_ctx *ctx)
{
int res;
SPHO_POSTCOND(ctx != NULL);
#ifdef SPHO_DEBUG
res = snprintf(ctx->errbuf, sizeof(ctx->errbuf),
"%s:%d:spho_syserr:%s (%d)", ctx->filebuf, ctx->errline,
@ -89,8 +96,8 @@ spho_ctx_sys_strerror(struct spho_ctx *ctx)
ctx->errbuf[sizeof(ctx->errbuf) - 1] = '\0';
#else
res = snprintf(ctx->errbuf, sizeof(ctx->errbuf),
"spho_syserr:%s (%d)", ctx->filebuf, ctx->errline,
strerror(ctx->err_info), ctx->err_info);
"spho_syserr:%s (%d)", strerror(ctx->err_info),
ctx->err_info);
if (res >= sizeof(ctx->errbuf))
ctx->errbuf[sizeof(ctx->errbuf) - 1] = '\0';
#endif