Compare commits

..

12 Commits

12 changed files with 431 additions and 0 deletions

View File

@ -0,0 +1,37 @@
<!--
This is part of WHY2
Copyright (C) 2022 Václav Šmejkal
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
-->
# why2_allocated
## Parameters
| Identifier | Data type |
| ---------- | --------- |
| `pointer` | `void *` |
## Attributes
| | |
| ------------------ | ----------------------------------------------------- |
| **Return type** | [`why2_bool`](../../../../types/core/flags/why2_bool) |
| **Header comment** | `CHECKS IF pointer WAS ALLOCATED USING WHY2-MEM` |
| **Added in commit** | [`65135ac96161eaa236b37ca2f3ace64345bbba66`](https://github.com/ENGO150/WHY2/commit/65135ac96161eaa236b37ca2f3ace64345bbba66) |
## Description
Function searches [`linked-list`](../../../../types/core/llist/why2_list_t) for `pointer`. If found, `false` is returned, otherwise `true` is returned.

View File

@ -0,0 +1,38 @@
<!--
This is part of WHY2
Copyright (C) 2022 Václav Šmejkal
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
-->
# why2_calloc
## Parameters
| Identifier | Data type |
| ---------- | --------------- |
| `element` | `unsigned long` |
| `size` | `unsigned long` |
## Attributes
| | |
| ------------------ | ---------------------------------------------- |
| **Return type** | `void *` |
| **Header comment** | *This functions doesn't have any description.* |
| **Added in commit** | [`3491d89a86eba805c3f42543a431cae33bae146b`](https://github.com/ENGO150/WHY2/commit/3491d89a86eba805c3f42543a431cae33bae146b) |
## Description
Function passes `element` and `size` into [`calloc`](https://linux.die.net/man/3/calloc) function and returns the output value. The value is also pushed to [`linked-list`](../../../../types/core/llist/why2_list_t) for garbage collector.

View File

@ -0,0 +1,39 @@
<!--
This is part of WHY2
Copyright (C) 2022 Václav Šmejkal
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
-->
# why2_clean_memory
## Parameters
| Identifier | Data type |
| ------------ | --------- |
| `identifier` | `char *` |
## Attributes
| | |
| ------------------ | ---------------------------------------------- |
| **Return type** | `void` |
| **Header comment** | `identifier SPECIFIES WHICH NODES TO DEALLOCATE | THIS IS BASICALLY GARBAGE COLLECTOR | PASS why2_get_default_memory_identifier() FOR DEALLOCATING EVERYTHING` |
| **Added in commit** | [`abbd82077821c3b06720212ca89f5d9438500a48`](https://github.com/ENGO150/WHY2/commit/abbd82077821c3b06720212ca89f5d9438500a48) |
## Description
This is basically a garbage collector.
Function [deallocates](../why2_deallocate) all memory allocated with WHY2-memory, with ID `identifier`. You can pass `why2_get_default_memory_identifier()` as `identifier` to deallocate all memory.

View File

@ -0,0 +1,37 @@
<!--
This is part of WHY2
Copyright (C) 2022 Václav Šmejkal
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
-->
# why2_deallocate
## Parameters
| Identifier | Data type |
| ---------- | --------- |
| `pointer` | `void *` |
## Attributes
| | |
| ------------------ | ---------------------------------------------- |
| **Return type** | `void` |
| **Header comment** | *This functions doesn't have any description.* |
| **Added in commit** | [`3491d89a86eba805c3f42543a431cae33bae146b`](https://github.com/ENGO150/WHY2/commit/3491d89a86eba805c3f42543a431cae33bae146b) |
## Description
Function passes `pointer` into corresponding deallocation function ([`free`](https://linux.die.net/man/3/free), [`fclose`](https://linux.die.net/man/3/fclose) or [`closedir`](https://linux.die.net/man/3/closedir)). The value is also removed from [`linked-list`](../../../../types/core/llist/why2_list_t).

View File

@ -0,0 +1,38 @@
<!--
This is part of WHY2
Copyright (C) 2022 Václav Šmejkal
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
-->
# why2_fdopen
## Parameters
| Identifier | Data type |
| ---------- | --------- |
| `file` | `int` |
| `modes` | `char *` |
## Attributes
| | |
| ------------------ | ---------------------------------------------- |
| **Return type** | `void *` |
| **Header comment** | *This functions doesn't have any description.* |
| **Added in commit** | [`1285f52b6737093f802163b3dc313253ea96f5bc`](https://github.com/ENGO150/WHY2/commit/1285f52b6737093f802163b3dc313253ea96f5bc) |
## Description
Function passes `file` and `modes` into [`fdopen`](https://linux.die.net/man/3/fdopen) function and returns the output value. The value is also pushed to [`linked-list`](../../../../types/core/llist/why2_list_t) for garbage collector.

View File

@ -0,0 +1,38 @@
<!--
This is part of WHY2
Copyright (C) 2022 Václav Šmejkal
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
-->
# why2_fopen
## Parameters
| Identifier | Data type |
| ---------- | --------- |
| `name` | `char *` |
| `modes` | `char *` |
## Attributes
| | |
| ------------------ | ---------------------------------------------- |
| **Return type** | `void *` |
| **Header comment** | *This functions doesn't have any description.* |
| **Added in commit** | [`1285f52b6737093f802163b3dc313253ea96f5bc`](https://github.com/ENGO150/WHY2/commit/1285f52b6737093f802163b3dc313253ea96f5bc) |
## Description
Function passes `name` and `modes` into [`fopen`](https://linux.die.net/man/3/fopen) function and returns the output value. The value is also pushed to [`linked-list`](../../../../types/core/llist/why2_list_t) for garbage collector.

View File

@ -0,0 +1,37 @@
<!--
This is part of WHY2
Copyright (C) 2022 Václav Šmejkal
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
-->
# why2_malloc
## Parameters
| Identifier | Data type |
| ---------- | --------------- |
| `size` | `unsigned long` |
## Attributes
| | |
| ------------------ | ---------------------------------------------- |
| **Return type** | `void *` |
| **Header comment** | *This functions doesn't have any description.* |
| **Added in commit** | [`9c7f40a82528846b6585294b12c5a30e5f1e4533`](https://github.com/ENGO150/WHY2/commit/9c7f40a82528846b6585294b12c5a30e5f1e4533) |
## Description
Function passes `size` into [`malloc`](https://linux.die.net/man/3/malloc) function and returns the output value. The value is also pushed to [`linked-list`](../../../../types/core/llist/why2_list_t) for garbage collector.

View File

@ -0,0 +1,37 @@
<!--
This is part of WHY2
Copyright (C) 2022 Václav Šmejkal
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
-->
# why2_opendir
## Parameters
| Identifier | Data type |
| ---------- | --------- |
| `name` | `char *` |
## Attributes
| | |
| ------------------ | ---------------------------------------------- |
| **Return type** | `void *` |
| **Header comment** | *This functions doesn't have any description.* |
| **Added in commit** | [`1285f52b6737093f802163b3dc313253ea96f5bc`](https://github.com/ENGO150/WHY2/commit/1285f52b6737093f802163b3dc313253ea96f5bc) |
## Description
Function passes `name` into [`opendir`](https://linux.die.net/man/3/opendir) function and returns the output value. The value is also pushed to [`linked-list`](../../../../types/core/llist/why2_list_t) for garbage collector.

View File

@ -0,0 +1,38 @@
<!--
This is part of WHY2
Copyright (C) 2022 Václav Šmejkal
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
-->
# why2_realloc
## Parameters
| Identifier | Data type |
| ---------- | --------------- |
| `pointer` | `void *` |
| `size` | `unsigned long` |
## Attributes
| | |
| ------------------ | ---------------------------------------------- |
| **Return type** | `void *` |
| **Header comment** | `THIS DOESN'T PRESERVE CONTENT OF pointer!` |
| **Added in commit** | [`8af6bd45c38e780bb14d99aee0a572b028c186b6`](https://github.com/ENGO150/WHY2/commit/8af6bd45c38e780bb14d99aee0a572b028c186b6) |
## Description
Function deallocates `pointer` (only applicable if `pointer` was allocated using WHY2-memory), passes `size` into [`malloc`](https://linux.die.net/man/3/malloc) function and returns the output value. The value is also pushed to [`linked-list`](../../../../types/core/llist/why2_list_t) for garbage collector.

View File

@ -0,0 +1,39 @@
<!--
This is part of WHY2
Copyright (C) 2022 Václav Šmejkal
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
-->
# why2_recalloc
## Parameters
| Identifier | Data type |
| ------------ | --------------- |
| `pointer` | `void *` |
| `size` | `unsigned long` |
| `block_size` | `unsigned long` |
## Attributes
| | |
| ------------------ | ------------------------------------------------------------ |
| **Return type** | `void *` |
| **Header comment** | `SAME AS why2_realloc BUT FILLS THE pointer WITH NULL-TERMS` |
| **Added in commit** | [`c5394e63e50e7c2e018a4323d33821c4f4e14884`](https://github.com/ENGO150/WHY2/commit/c5394e63e50e7c2e018a4323d33821c4f4e14884) |
## Description
Function deallocates `pointer` (only applicable if `pointer` was allocated using WHY2-memory), passes `size` and `block_size` into [`calloc`](https://linux.die.net/man/3/calloc) function and returns the output value. The value is also pushed to [`linked-list`](../../../../types/core/llist/why2_list_t) for garbage collector.

View File

@ -0,0 +1,37 @@
<!--
This is part of WHY2
Copyright (C) 2022 Václav Šmejkal
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
-->
# why2_strdup
## Parameters
| Identifier | Data type |
| ---------- | --------- |
| `string` | `char *` |
## Attributes
| | |
| ------------------ | ---------------------------------------------- |
| **Return type** | `void *` |
| **Header comment** | *This functions doesn't have any description.* |
| **Added in commit** | [`d5ae68c621b61823dc18cf7fe2d93dfb036cbbc1`](https://github.com/ENGO150/WHY2/commit/d5ae68c621b61823dc18cf7fe2d93dfb036cbbc1) |
## Description
Function passes `string` into [`strdup`](https://linux.die.net/man/3/strdup) function and returns the output value. The value is also pushed to [`linked-list`](../../../../types/core/llist/why2_list_t) for garbage collector.

View File

@ -85,6 +85,22 @@ You can find documentation for every *public* function of WHY2 below.
| [`why2_list_get_size`](./core/llist/why2_list_get_size) | Get size |
| [`why2_list_reverse`](./core/llist/why2_list_reverse) | Reverses list |
### Memory
| Function | Description |
| ------------------------------------------------------ | ---------------------------------------------------------- |
| [`why2_malloc`](./core/memory/why2_malloc) | *This functions doesn't have any description.* |
| [`why2_calloc`](./core/memory/why2_calloc) | *This functions doesn't have any description.* |
| [`why2_realloc`](./core/memory/why2_realloc) | This doesn't preserve content of pointer! |
| [`why2_recalloc`](./core/memory/why2_recalloc) | Same as why2_realloc but fills the pointer with null-terms |
| [`why2_strdup`](./core/memory/why2_strdup) | *This functions doesn't have any description.* |
| [`why2_fopen`](./core/memory/why2_fopen) | *This functions doesn't have any description.* |
| [`why2_fdopen`](./core/memory/why2_fdopen) | *This functions doesn't have any description.* |
| [`why2_opendir`](./core/memory/why2_opendir) | *This functions doesn't have any description.* |
| [`why2_deallocate`](./core/memory/why2_deallocate) | *This functions doesn't have any description.* |
| [`why2_clean_memory`](./core/memory/why2_clean_memory) | identifier specifies which nodes to deallocate \| this is basically garbage collector \| pass why2_get_default_memory_identifier() for deallocating everything |
| [`why2_allocated`](./core/memory/why2_allocated) | Checks if pointer was allocated using why2-mem |
## Logger
## Chat