Skip to content

Latest commit

History

8 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

my-c-array

Dynamic array implementation in C with a modular, folder-based structure.

🔧 Features

  • 🧩 Modular Operations: Efficient functions for array append, prepend, resize, delete, and access.
  • 🛠️ Custom Memory Management: Define custom free functions for array element deallocation.
  • 🔓 Expandable: Easily extendable with additional array-related functions.
  • 🌍 Cross-Platform: Build scripts for both Linux (bash or make) and Windows (batch).
  • 📂 Organized Structure: Each module is in its own directory for easy maintenance.
  • 📚 Static Library: Compiles into libmyarray.a for easy reuse in other projects.
  • ⚙️ C Standard: Written in pure C for maximum compatibility.
  • 🚀 Easy to Build: Simple setup for compiling and integrating into other projects.

🗂️ Suggested Directory Layout

my-c-array/
├── Makefile
├── build.sh
├── build.bat
├── libmyarray.a (after build)
├── src/
│ ├── array_append/
│ │ ├── array_append.c
│ │ └── array_append.h
│ └── ...

🛠️ Build Instructions

Linux / macOS

chmod +x build.sh
./build.sh

Or using make:

make

Windows

build.bat

This will compile the source files under src/, place the object files in build/, and generate a static library libmyarray.a or an executable if you add a main.c.

📦 Functions

  • Modular directory layout
  • Cross-platform build scripts (.sh and .bat)
  • Basic operations like:
    • array_create
    • array_append
    • array_delete
    • array_get
    • array_resize
    • array_prepend
    • array_size

📄 Example Header

Here’s what the base array type looks like:

#ifndef_ARRAY_TYPE_H_#define_ARRAY_TYPE_H_#include<stddef.h>// for size_ttypedefvoid (*array_free_func_t)(void*);
typedefstruct {
void**items; // actual datasize_tcapacity; // total capacitysize_tsize; // current number of elementsarray_free_func_tfreer; // custom free function (NULL means no-op)
} array_t;
#endif

📜 License

MIT License
© 2025 Max Base

About

Dynamic array implementation in C with a modular, folder-based structure.

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages