@@ -1121,6 +1121,60 @@ RL_API REBSER* RL_Decode_UTF_String(REBYTE *src, REBCNT len, REBINT utf, REBFLG
1121
1121
return Decode_UTF_String (src , len , utf , ccr , uni );
1122
1122
}
1123
1123
1124
+ /***********************************************************************
1125
+ **
1126
+ */ RL_API REBCNT RL_Register_Handle (REBYTE * name , REBCNT size , void * free_func )
1127
+ /*
1128
+ ** Stores handle's specification (required data size and optional free callback.
1129
+ **
1130
+ ** Returns:
1131
+ ** table index for the word (whether found or new)
1132
+ ** or NOT_FOUND if handle with give ID is already registered.
1133
+ ** Arguments:
1134
+ ** name - handle's name as a c-string (length is being detected)
1135
+ ** size - size of needed memory to handle
1136
+ ** free_func - custom function to be called when handle is released
1137
+ **
1138
+ ***********************************************************************/
1139
+ {
1140
+ REBCNT sym ;
1141
+ REBCNT len ;
1142
+ // Convert C-string to Rebol word
1143
+ len = strlen (cs_cast (name ));
1144
+ sym = Scan_Word (name , len );
1145
+ if (!sym ) return NOT_FOUND ; //TODO: use different value if word is invalid?
1146
+ return Register_Handle (sym , size , (REB_HANDLE_FREE_FUNC )free_func );
1147
+ }
1148
+
1149
+ RL_API REBHOB * RL_Make_Handle_Context (REBCNT sym )
1150
+ /*
1151
+ ** Allocates memory large enough to hold given handle's id
1152
+ **
1153
+ ** Returns:
1154
+ ** A pointer to a Rebol's handle value.
1155
+ ** Arguments:
1156
+ ** sym - handle's word id
1157
+ **
1158
+ ***********************************************************************/
1159
+ {
1160
+ return Make_Handle_Context (sym );
1161
+ }
1162
+
1163
+ RL_API void RL_Free_Handle_Context (REBHOB * hob )
1164
+ /*
1165
+ ** Frees memory of given handle's context
1166
+ **
1167
+ ** Returns:
1168
+ ** nothing
1169
+ ** Arguments:
1170
+ ** hob - handle's context
1171
+ **
1172
+ ***********************************************************************/
1173
+ {
1174
+ Free_Hob (hob );
1175
+ }
1176
+
1177
+
1124
1178
1125
1179
1126
1180
#include "reb-lib-lib.h"
0 commit comments