mirror of
https://github.com/CPunch/Cosmo.git
synced 2026-01-02 13:50:18 +00:00
Added boilerplate for CObjStream
This commit is contained in:
14
src/cobj.c
14
src/cobj.c
@@ -7,6 +7,7 @@
|
||||
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
#include <unistd.h>
|
||||
|
||||
// we don't actually hash the whole string :eyes:
|
||||
uint32_t hashString(const char *str, size_t sz) {
|
||||
@@ -54,6 +55,12 @@ void cosmoO_free(CState *state, CObj *obj) {
|
||||
cosmoM_free(state, CObjObject, objTbl);
|
||||
break;
|
||||
}
|
||||
case COBJ_STREAM: {
|
||||
CObjStream *objStrm = (CObjStream*)obj;
|
||||
close(objStrm->fd);
|
||||
cosmoM_free(state, CObjStream, objStrm);
|
||||
break;
|
||||
}
|
||||
case COBJ_TABLE: {
|
||||
CObjTable *tbl = (CObjTable*)obj;
|
||||
cosmoT_clearTable(state, &tbl->tbl);
|
||||
@@ -181,6 +188,13 @@ CObjObject *cosmoO_newObject(CState *state) {
|
||||
return obj;
|
||||
}
|
||||
|
||||
CObjStream *cosmoO_newStream(CState *state, int fd) {
|
||||
CObjStream *strm = (CObjStream*)cosmoO_allocateBase(state, sizeof(CObjStream), COBJ_STREAM);
|
||||
strm->fd = fd;
|
||||
|
||||
return strm;
|
||||
}
|
||||
|
||||
CObjTable *cosmoO_newTable(CState *state) {
|
||||
CObjTable *obj = (CObjTable*)cosmoO_allocateBase(state, sizeof(CObjTable), COBJ_TABLE);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user