some fixes

This commit is contained in:
Nishi 2026-09-23 18:14:10 +09:00
commit 9c671b8527
3 changed files with 16 additions and 16 deletions

View file

@ -82,21 +82,21 @@ Sj4Context* alloccontext(const char* dic) {
if(ctx == NULL) return NULL; if(ctx == NULL) return NULL;
if((ctx->work = calloc(1, sizeof(*ctx->work))) == NULL) { if((ctx->work = calloc(1, sizeof(*ctx->work))) == NULL) {
free(ctx); free((char*)ctx);
return NULL; return NULL;
} }
if((ctx->stdy = calloc(1, sizeof(*ctx->stdy))) == NULL) { if((ctx->stdy = calloc(1, sizeof(*ctx->stdy))) == NULL) {
free(ctx->work); free((char*)ctx->work);
free(ctx); free((char*)ctx);
return NULL; return NULL;
} }
if((node = calloc(1, sizeof(*node))) == NULL) { if((node = calloc(1, sizeof(*node))) == NULL) {
free(ctx->stdy); free((char*)ctx->stdy);
free(ctx->work); free((char*)ctx->work);
free(ctx); free((char*)ctx);
return NULL; return NULL;
} }
@ -128,19 +128,19 @@ void free_context(Sj4Context* ctx) {
DICTL* next = node->next; DICTL* next = node->next;
if(node->dict != NULL) closedict(ctx, (DictFile*)node->dict); if(node->dict != NULL) closedict(ctx, (DictFile*)node->dict);
free(node); free((char*)node);
node = next; node = next;
} }
freework(ctx); freework(ctx);
if(ctx->jrec_pool != NULL) free(ctx->jrec_pool); if(ctx->jrec_pool != NULL) free((char*)ctx->jrec_pool);
if(ctx->clrec_pool != NULL) free(ctx->clrec_pool); if(ctx->clrec_pool != NULL) free((char*)ctx->clrec_pool);
free(ctx->stdy); free((char*)ctx->stdy);
free(ctx->work); free((char*)ctx->work);
free(ctx); free((char*)ctx);
} }
#endif #endif

View file

@ -42,7 +42,7 @@ Sj4Ime* sj4_ime(int charset, const char* dict, Sj4ImePacket packet) {
if((ime = calloc(1, sizeof(*ime))) == NULL) return NULL; if((ime = calloc(1, sizeof(*ime))) == NULL) return NULL;
if((ime->lib = sj4_open(charset, dict)) == NULL) { if((ime->lib = sj4_open(charset, dict)) == NULL) {
free(ime); free((char*)ime);
return NULL; return NULL;
} }
@ -236,5 +236,5 @@ void* sj4_ime_convbuf(Sj4Ime* ime) {
void sj4_ime_close(Sj4Ime* ime) { void sj4_ime_close(Sj4Ime* ime) {
sj4_close(ime->lib); sj4_close(ime->lib);
free(ime); free((char*)ime);
} }

View file

@ -28,7 +28,7 @@ Sj4Lib* sj4_open(int charset, const char* dic) {
if((ctx = calloc(1, sizeof(*ctx))) == NULL) return NULL; if((ctx = calloc(1, sizeof(*ctx))) == NULL) return NULL;
if((ctx->ctx = alloccontext(dic)) == NULL) { if((ctx->ctx = alloccontext(dic)) == NULL) {
free(ctx); free((char*)ctx);
return NULL; return NULL;
} }
@ -96,5 +96,5 @@ int sj4_prevkan(Sj4Lib* ctx) {
void sj4_close(Sj4Lib* ctx) { void sj4_close(Sj4Lib* ctx) {
free_context(ctx->ctx); free_context(ctx->ctx);
free(ctx); free((char*)ctx);
} }