detect_destroy(3)
π detect_destroy β free Detector structure π
okay bestie, this is page three of the libchardet library functions manual, and honestly? it's a short one, but it's SO important. it's giving cleanup era. β¨
πΈ NAME πΈ
detect_destroy β free Detector structure
like, it frees the Detector structure. that's the whole job. and it ate. π
π SYNOPSIS π
#include <chardet.h>
void detect_destroy (Detect ** handle);
that's it. one function, one argument, no return. lowkey iconic for being so simple. π¦
β¨ DESCRIPTION β¨
Free resource that allocated by detect_init api.
so basically β remember that memory your girl detect_init handed you? the one you've been holding onto this whole time? yeah. this is where you give it back. detect_destroy frees the resource that was allocated by the detect_init api. no cap. π₯
not you forgetting to call this and leaking memory... couldn't be you bestie. please call it. π
π RETURN VALUE π
void
she returns nothing. she gives nothing back. she just takes the memory away and leaves. main character energy fr fr. π
π EXAMPLE π
here's the whole vibe in code, exactly as it goes:
#include <chardet.h>
int main (void) {
Detect * d;
DetectObj * obj;
if ( (d = detect_init ()) == NULL ) {
fprintf (stderr, "chardet handle initialize failed\n");
return CHARDET_MEM_ALLOCATED_FAIL;
}
detect_reset (&d);
if ( (obj = detect_obj_init ()) == NULL ) {
fprintf (stderr, "Memory Allocation failed\n");
return CHARDET_MEM_ALLOCATED_FAIL;
}
switch (detect_handledata (&d, "μλ
νμΈμ", &obj)) {
case CHARDET_OUT_OF_MEMORY :
fprintf (stderr, "On handle processing, occured out of memory\n");
detect_obj_free (&obj);
return CHARDET_OUT_OF_MEMORY;
case CHARDET_NULL_OBJECT :
fprintf (stderr,
"3st argument of chardet_handledata() is must memory allocation "
"with detect_obj_init API\n");
return CHARDET_NULL_OBJECT;
}
# check support obj->bom with CHARDET_BOM_CHECK constant
printf ("encoding: %s, confidence: %f, exists bom: %d\n", obj->encoding, obj->confidence, obj->bom);
detect_obj_free (&obj);
detect_destroy (&d);
return 0;
}
see how detect_destroy (&d); shows up right at the end, after detect_obj_free (&obj);? that's the order bestie. clean up the obj, then clean up the handle. the way that it all comes full circle... π«Ά
π§ AUTHORS π§
JoungKyun.Kim <http://oops.org>
ty for your service king π«‘
π BUG REPORTS π
Use QnA board on https://github.com/Joungkyun/libchardet/issues
found something cursed? take it there, don't suffer in silence. πΈ
π¦ SEE ALSO π¦
detect_init(3), detect_reset(3)
and that's the page!! this lil slice of the libchardet manuals is dated 2019-08-01, and it lives under the Library Functions Manual umbrella. periodt. π
β¨π
π¦ where this page comes from
- arch rolling: libchardet 1.0.6-4 Β· MPL-1.1
- debian trixie: libchardet-dev 1.0.6-1 Β· MPL-1.1 OR GPL-2.0-or-later OR LGPL-2.1-or-later
- nixos 26.05: libchardet 1.0.6
- nixpkgs unstable: libchardet 1.0.6
- ubuntu questing: libchardet-dev 1.0.6-1
- ubuntu resolute: libchardet-dev 1.0.6-2 Β· MPL-1.1 OR GPL-2.0-or-later OR LGPL-2.1-or-later
- ubuntu stonking: libchardet-dev 1.0.6-2 Β· MPL-1.1 OR GPL-2.0-or-later OR LGPL-2.1-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms